Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Although it is possible to enumerate all the files on the computer, this procedure can be extremely slow, and typically yields far more information than you can make use of. A faster, and generally more useful, approach is to enumerate all the files in a particular folder. This allows you to do such things as verify that each of your servers has a Scripts folder containing a full set of system administration scripts. Likewise, you might want to connect to an application folder and verify the version number for each .dll file stored there.
To enumerate all the files in a folder, you can use a script similar to the one shown in Listing 11.19. The only difference is that you include a Where clause in your WQL query to restrict data retrieval to those files found in the specified folder.
Listing 11.21 contains a script that returns a list of all the files in the folder C:\Scripts. To carry out this task, the script must perform the following steps:
To limit data retrieval to the files in a specific folder, a Where clause is included restricting the returned files to those with the path \\Scripts\\. (You must include double backslashes [\\] before and after the path name.) Note that you do not have to include the drive letter provided the path is unique within the file system.
Listing 11.21 Enumerating All the Files in a Folder
|
|
Send us your feedback | « Previous | Next » |