Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
In addition to copying entire folders, you often need to copy individual files or specific sets of files. For example, you might need to copy a particular template to each computer or copy all .vbs files to a new administrator workstation. The CIM_Datafile Copy method can be used to copy individual files or a set of files from one location to another.
This ability to copy individual files (as opposed to entire folders) is especially powerful when combined with WMI s ability to locate all the files of a specified type regardless of their location in the file system. This allows you to perform such tasks as automatically searching for all .log files and copying them to a central monitoring station, or searching for all Microsoft Word files and copying them to a document repository.
You can use the CIM_DataFile class and the Copy method to copy either a single file or a set of files to a new location.
Listing 11.25 contains a script that copies all the Microsoft® Windows Media® files on a computer to a specified folder. To carry out this task, the script must perform the following steps:
To limit data retrieval to Windows Media files, a Where clause is included restricting the returned files to those with the extension .wma.
For example, if you have a file named D:\Finance\Annual Meeting.wma, the value of strCopy is C:\Media Archive\Annual Meeting.wma.
Listing 11.25 Copying Files
|
|
Send us your feedback | « Previous | Next » |