HOW TO: Use the File Version Script Tool (Fileversion.pl) in Microsoft Windows 2000 (318764)



The information in this article applies to:

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional

This article was previously published under Q318764

SUMMARY

This step-by-step article describes how to use the File Version Script tool (Fileversion.pl) to display version information about files that reside on local and remote Microsoft Windows 2000-based computers.

The File Version Script tool is available in Microsoft Windows 2000 Resource Kit Supplement 1. Use this script tool to display the version number of files on NTFS volumes of local or remote computers. If the file is copyrighted, you can display the name of the company that holds the copyright. Executable (.exe) files and dynamic link library (.dll) files are examples of copyrighted files. Fileversion.pl also displays information about other file properties such as file size, location, and the date and time the file was last modified.

The version information that Fileversion.pl displays corresponds to the information that appears on the Version tab of the Properties dialog box of a copyrighted file. To view this information in Microsoft Windows Explorer, right-click a copyrighted file (for example, Winhlp32.exe in the Winnt folder), click Properties, and then click the Version tab.

back to the top

System Requirements for Fileversion.pl

Fileversion.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 display version information of files on local or remote computers, the following requirements must be met.

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.
  • You are logged on by using a user account that is a member of the administrators group on the target computer.
back to the top

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.
back to the top

Overview of Fileversion.pl

Fileversion.pl uses the following syntax:

fileversion.pl Folder| File [ Folder| File...] [ -s Computer [ -u Domain\User -p Password]][ -format table| list | csv] [ -v][ -unittype B| KB | MB][ -recurse][ -filter "FieldOperatorValue" [ -filter "FieldOperatorValue"...]]

The parameters that you can use with Fileversion.pl are:
  • Folder | File [ Folder | File...]: Use this parameter to specify the files whose version information you want to display by using the following format: drive:\folder\filename.

    You can use the wildcard character (*) in any position in the path. If you specify a folder, Fileversion.pl displays the version information of all files in the folder. 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 with 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 Fileversion.pl. If you omit this parameter, Fileversion.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.
    Both the -p and -u parameters are available only when you use the -s parameter.

    NOTE: If the remote volume is mapped to a drive on the local computer, you can specify the mapped drive letter in the file path. For example, J:\Winnt\*.exe. You do not need to use the -s parameter to indicate another computer.

  • -format table|list| csv: Use this parameter to specify the output format. If you omit this parameter, Fileversion.pl uses, by default, the table format.
  • -v: Use this parameter to add the Company Name entry to the display.
  • -unittype B|KB| MB: Use this parameter to specify the unit of disk space that is used to display the file size. If you omit this parameter, Fileversion.pl uses kilobytes (KB) by default.
  • -recurse: Use this parameter to add files in subfolders of the specified folders to the display. If you omit this parameter, only files that are in the specified folders are included in the display.
  • -filter "FieldOperatorValue" [-filter "FieldOperatorValue"...]: Use this parameter to specify the criteria for 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. Fileversion.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":
FieldOperatorValueExample
FILENAME= !File names or file name patterns. You can use the wildcard character (*) in any position in the file name or extension."filename=*.exe"
SIZEAll logical operatorsNumberUnit"size>=1MB"
VERSION= !Version Number | NONE (matches exact strings only)."version=5.0.8.8"
"version!NONE
DATETIMEAll logical operatorsThe last modified date, where Date is in mm/dd/yyyy format or Date:Time is in mm/dd/yyyy:hh:mm:ss [am|pm] format"datetime>03/01/2002:8:30:00PM"
PATH=!Valid paths and files names or *."path!c:winnt"
COMPANYNAME= !Company name. (Matches exact strings only.)"companyname=Microsoft Corporation"


back to the top

Examples

  1. To display the version and company name that holds the copyright to the Explorer.exe file in the C:\Winnt folder of the local computer, type the following line at the command prompt, and then press ENTER:

    fileversion.pl c:\winnt\explorer.exe -v

  2. To display the versions and exact size in bytes of all of the .dll files that are in C:\Inetpub folder and its subfolders of the local computer, and then display the output in list format, type the following line at the command prompt, and then press ENTER:

    fileversion.pl c:\inetpub\*.dll -format list -unittype b -recurse

  3. To display the versions and company names that hold the copyright to all .exe and .dll files in the C:\Winnt\System32 folder of the local computer in comma-delimited format, and then redirect the output to the E:\Ver\Sys32ver.csv file, type the following line at the command prompt, and then press ENTER:

    fileversion.pl c:\winnt\system32\*.dll C:\winnt\system32\*.exe -format csv -v > e:\ver\sys32ver.csv

  4. To run Fileversion.pl by using the Administrator account to display the versions of all .exe files in the C:\Program Files\Microsoft Office folder and its subfolders of a remote computer that is named Server8, display the output in list format, and then redirect the output to a file that is named Version.txt in the root folder of drive E, type the following line at the command prompt, and then press ENTER:

    fileversion.pl "c:\Program Files\Microsoft Office\*.exe" -s server8 -u server8\administrator -p password -format list > e:\version.txt -recurse

  5. To display the version information of all .exe files from the MyCompany Corporation that were modified before March 1, 2002 in the Z:\Program files\MyApp folder and all subfolders (with the exception the Temp folder), 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 the C: drive of a remote computer.

    fileversion.pl "z:\program files\myapp \*.exe" -recurse -filter "companyname=mycompany corp" -filter "path!z:\program files\myapp\temp" -filter "datetime<03/01/2002"

back to the top

Troubleshooting

When you try to run Fileversion.pl, you may 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 Fileversion.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 where you will 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.
  2. 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.
back to the top

REFERENCES

For more information about the Windows 2000 Resource Kit and the Windows 2000 Resource Kit Supplement 1, visit the following Microsoft Web site: back to the top

Modification Type:MajorLast Reviewed:9/27/2006
Keywords:kbenv kbhowto kbHOWTOmaster kbnetwork KB318764 kbAudITPro