SUMMARY
This step-by-step article describes how to use the File
Attribute Management Script tool (Fileattributes.pl) to configure compression
and display the attributes of folders and files on local and remote Microsoft
Windows 2000-based computers.
The File Attribute Management Script
tool is available in the
Microsoft Windows 2000 Resource Kit Supplement 1. Use this script tool to complete the following tasks on files or
folders of NTFS volumes on computers that are running Windows 2000:
- Display the attributes of files and folders. The following
list describes the attributes that Fileattributes.pl displays, and lists the
letters that Fileattributes.pl uses to represent them:
- A: Archived. The file or folder can be archived.
- C: Compressed. The file or folder is compressed.
- E: Encrypted. The contents of the file or folder are encrypted.
- H: Hidden. The file or folder is hidden, which means that it does
not appear in Windows Explorer or in folder lists.
- R: Read-only. The file or the contents of the folder is read-only,
which means that it cannot be changed or accidentally deleted.
- S: System. The file is a system file which is used to load,
configure, or run Windows 2000.
- Turn on or turn off compression of files and
folders.
The information that Fileattributes.pl displays corresponds to
the information that appears in the
Attributes section of the
General tab of the
Properties dialog box of a folder or file. To view this information in
Microsoft Windows Explorer, right-click a folder or file, click
Properties, and then click the
General tab.
System Requirements for Fileattributes.pl
Fileattributes.pl runs on a source computer and acts on a target
computer (which can be the same or different computer than the source
computer). Before you can use this script tool to configure the compression of
or display the attributes of folders and files on NTFS volumes of local or
remote computers, the following requirements must be met on the source and
target computers.
Source Computer
- The computer is running either Windows 2000 Professional or
Windows 2000 Server.
- ActiveState ActivePerl Build 521 is installed. This program
is available in the Windows 2000 Resource Kit.
The computer must also be correctly configured to run
the Perl scripts that are included in the Windows 2000 Resource Kit Supplement 1. The resource kit WMI provider module, Wmi.pm, must be in the Perl Installation Folder\Site\Lib\W2rk folder. The resource kit Setup program typically
creates the W2rk folder and copies the Wmi.pm file to this folder.
If the W2rk folder is not automatically created during Setup, you can manually
create it and then configure the environment in which to run Fileattributes.pl.
For more information about how to do this, see the
"Troubleshooting" section later in
this article. - You are logged on by using a user account that is a member
of the administrators group on the target computer.
Target Computer
- The computer is running either Windows 2000 Professional or
Windows 2000 Server
- The computer contains volumes that are formatted with the
NTFS file system.
Overview of Fileattributes.pl
Fileattributes.pl uses the following general syntax:
fileattributes.pl -operation
where
-operation is one of the following commands that you can pass to the script.
The following list describes each operation that you can use with
Fileattributes.pl:
-change: Use this operation to turn on or turn off compression for folders and files.
-query: Use this operation to display the attributes of folders and files.
Each operation uses its own syntax.
Change
The
fileattributes.pl -change statement
uses the following syntax:
fileattributes.pl -change Folder| File [ Folder| File...] [ -s Computer [ -u Domain\User -p Password]][ -compress
on| off][ -recurse]
The parameters that you can use with
fileattributes.pl
-change are:
- Folder | File [ Folder | File...]: Use this parameter to specify the folder or
file that you want to compress using the following format: Drive:\Folder\FileName.
You can use the wildcard character (*) in any
position in the path. If you want to specify two or more folders or files,
separate each item with a space. If the folder or file name contains a space,
enclose the folder or file name and path in quotation marks ("").
When the file or folder is on a volume that is not mapped to the local
computer, use the relative path (the path as it is seen from the remote
computer). - -s Computer: Use this parameter to specify the name or IP
address of a remote computer. If you omit this parameter, the local computer is
specified.
- -u Domain\User: Use this parameter to specify the user account with
which to run Fileattributes.pl. If you omit this parameter, Fileattributes.pl
uses the permissions of the currently logged-on user. If you use this
parameter, you must also use the -p parameter to provide the user's password.
- -p Password: Use this parameter to specify the password of the
user account that is specified by the -u parameter. The -p parameter is required when you use the -u parameter.
Note Both the -p and -u parameters are available only when you use the -s parameter.
- -compress on | off: Use this parameter to turn on or turn off compression for the
specified folders or files.
- -recurse: Use this parameter to extend the command to all child objects of
the specified folder. If you omit this parameter, only the specified folder and
the files in that folder are affected. Subfolders and the files that are
contained in them are not affected.
Query
The
fileattributes.pl -query statement
uses the following syntax:
fileattributes.pl Folder| File [ Folder| File...] [ -s Computer [ -u Domain\User -p Password]][ -recurse][ -format
table| list |
csv][ -filter "FieldOperatorValue" [ -filter "FieldOperatorValue"...]]
The parameters that you can use
with
fileattributes.pl -query are:
- Folder | File [ Folder | File...]: Use this parameter to specify the folder or
file that you want to display using the following format: Drive:\Folder\FileName.
You can use the wildcard character (*) in any
position in the path. If you want to specify two or more folders or files,
separate each item with a space. If the folder or file name contains a space,
enclose the folder or file name and path in quotation marks ("").
When the file or folder is on a volume that is not mapped to the local
computer, use the relative path (the path as it is seen from the remote
computer). - -s Computer: Use this parameter to specify the name or IP
address of a remote computer. If you omit this parameter, the local computer is
specified.
- -u Domain\User: Use this parameter to specify the user account with
which to run Fileattributes.pl. If you omit this parameter, Fileattributes.pl
uses the permissions of the currently logged-on user. If you use this
parameter, you must also use the -p parameter to provide the user's password.
- -p Password: Use this parameter to specify the password of the
user account that is specified by the -u parameter. The -p parameter is required when you use the -u parameter.
Note Both the -p and -u parameters are available only when you use the -s parameter. - -recurse: Use this parameter to display the attributes of the specified
folder and all child objects of the specified folder. If you omit this
parameter, only the specified folder and the files that are contained in that
folder are included in the display.
- -format table|list| csv: Use this parameter to specify the output format. By default, if
you omit this parameter, Fileattributes.pl uses the table format.
- -filter "FieldOperatorValue" [-filter "FieldOperatorValue"...]: Use this parameter to specify the criteria for
folders and files that are included in the display. If you omit this parameter,
all items that are specified in the Folder | File parameter are included in the display.
To establish
more than one criteria, use a separate instance of -filter "FieldOperatorValue" for each criteria that you want to specify, and separate each
instance with a space. Fileattributes.pl displays only those files and folders
that meet all of the criteria.
The following table lists the
operators and values that are available for each field that is used with the -filter parameter, and an example of each "FieldOperatorValue".
|
TYPE | = ! | file |
folder | "type=file" |
PATH | = ! | Valid path and file names. Wildcard
characters (*) are permitted. | "path\file!e:\winnt\system32\*.dll" |
ATTRIBUTE | = ! | One or more of the following
abbreviations without spaces: A | C | E | H | R | S | "attribute=C"
"attribute!HS" |
Examples
- To compress the E:\Reports folder and the files that are
contained in this folder on the local computer, type
fileattributes.pl -change -compress on e:\reports at the
command prompt, and then press ENTER.
- To compress the E:\Reports folder and all child objects of
this folder (all subfolders and files that are contained in the subfolders),
type fileattributes.pl -change -compress on -recurse
e:\reports at the command prompt, and then press ENTER.
- To run Fileattributes.pl by using the administrator account
to compress the D:\My Graphics folder of a remote computer that is named
Server8 in the Corp domain, type fileattributes.pl -change -compress
on "d:\my graphics" -s server8 -u corp\administrator -p password at the command prompt, and then press
ENTER.
- To display the attributes of only files in the C:\*.*
folder of the local computer, type fileattributes.pl -query c:\*.*
-format list -filter "type=file" at the command prompt, and then
press ENTER.
- To display the attributes of all files in the E:\Pictures
folder, display the output in a comma-delimited format, and then redirect the
output to a file that is named Pictures.csv in the C:\Attributes folder of the
local computer, type fileattributes.pl -query e:\pictures\*.*
-recurse -format csv > c:\attributes\pictures.csv at the command
prompt, and then press ENTER.
- To display the files in the E:\Pictures folder that are
archived, read-only, and compressed, type fileattributes.pl -query
e:\pictures\*.* -filter "attribute=ARC" at the command prompt, and
then press ENTER.
- To display all encrypted files that are on volumes E, F,
and Z, type the following line at the command prompt, and then press ENTER.
Note In this example, the Z drive on the local computer is mapped to
drive C of a remote computer. If the remote volume is mapped to a drive on the
local computer, you can specify the mapped drive letter in the file path. You
do not need to use the -s parameter to indicate another computer. fileattributes.pl -query e: f: z: -recurse -filter "attribute=e"
Troubleshooting
When you try to run Fileattributes.pl, you receive the following
error message:
ERROR: Wmi.pm is required to run the
script.
Copy Wmi.pm from the Resource Kit directory to
/Perl/site/lib/W2RK.
This behavior can occur if the computer is not
correctly configured to run the Perl scripts that are included in the
Windows 2000 Resource Kit Supplement 1. To use Fileattributes.pl, the W2rk folder must exist in the
Perl Installation Folder\site\lib folder, and it must contain the Wmi.pmi file.
To resolve this behavior, manually configure the environment in which to run
Perl scripts:
- Create a folder that is named W2rk in the Perl Installation Folder\Site\Lib folder.
Note The default Perl Installation Folder is drive:\Perl, where drive is the drive on which Windows is installed. - Copy the Wmi.pmi file from the folder in which the Windows 2000 Resource Kit is installed (by default, it is \Program Files\Resource Kit) to
the W2rk folder that you created in step 1.
REFERENCES
For more information about file and folder compression in Windows
2000, click the following article numbers to view the articles in the Microsoft Knowledge Base:
251186
Best practices for NTFS compression in Windows
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
223316
Best practices for the Encrypting File System
For more information about how to use the
File Version Script Tool (Fileversion.pl) to display version information of
files on Windows 2000-based computers, click the following article number to view the article in the Microsoft Knowledge Base:
318764
How to use the File Version script tool (Fileversion.pl) in Microsoft Windows 2000
For more information about the
Windows 2000 Resource Kit and the
Windows 2000 Resource Kit Supplement 1, visit the following Microsoft Web site: