Microsoft KB Archive/320050

= HOW TO: Use the File Attribute Management Script (Fileattributes.pl) in Windows 2000 =

Article ID: 320050

Article Last Modified on 11/1/2006

-

APPLIES TO


 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition

-



This article was previously published under Q320050





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 &quot;Troubleshooting&quot; 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 (&quot;&quot;).

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.</li></ul>

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 &quot;FieldOperatorValue&quot; [ -filter &quot;FieldOperatorValue&quot; ...]]

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 (&quot;&quot;).

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).</li> -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.</li> -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.</li></ul>

Note Both the -p and -u parameters are available only when you use the -s parameter.</li> -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.</li> -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.</li> -filter  [-filter &quot;FieldOperatorValue&quot;...]: 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 |   parameter are included in the display.

To establish more than one criteria, use a separate instance of -filter &quot;FieldOperatorValue&quot; 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 &quot;FieldOperatorValue&quot;.</li></ul>

Examples
<ol> 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.</li> 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.</li> 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 &quot;d:\my graphics&quot; -s server8 -u corp\administrator -p password at the command prompt, and then press ENTER.</li> To display the attributes of only files in the C:\*.* folder of the local computer, type fileattributes.pl -query c:\*.* -format list -filter &quot;type=file&quot; at the command prompt, and then press ENTER.</li> 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.</li> To display the files in the E:\Pictures folder that are archived, read-only, and compressed, type fileattributes.pl -query e:\pictures\*.* -filter &quot;attribute=ARC&quot; at the command prompt, and then press ENTER.</li> <li>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 &quot;attribute=e&quot;

</li></ol>

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:
 * 1) 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.
 * 1) 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.

<div class="references_section">