Managing Files Using WMI

Microsoft® Windows® 2000 Scripting Guide

Managing files by using scripts is similar to managing folders. WMI treats files and folders as if they were essentially the same type of object; in fact, the properties and methods of the Win32_Directory and CIM_DataFile classes are identical. Files and folders are also similar in that they are not static entities; when you create a new file named C:\Scripts\ScriptLog.txt, there is no guarantee that it will be in the same place, under the same name, a year from now.

Instead, files might be renamed or be given a new file name extension. Files might be copied to multiple servers, moved to new locations, or deleted altogether. All of these tasks - and more - can be carried out programmatically using WMI and the Shell object.