Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Standardization helps facilitate system administration. For example, having a standard set of folder names makes it easier to run scripts that verify that the proper set of files has been installed on a computer. With standard folder names, scripts such as these can simply connect to the desired folders without needing a list of unique folder names and locations for each individual computer.
Scripts can help you implement standardized naming schemes on computers throughout your organization. For example, the Win32_Directory class provides a Rename method that allows you to rename a folder. Thus, you can write a script that connects to all the domain controllers in your organization and renames the folder C:\Stuff to C:\Administrative Scripts.
To rename a folder, first bind to the folder in question and then call the Rename method. As the sole parameter to the method, pass the new name for the folder as a complete path name. For example, if the folder in the C:\Scripts\Logs\Backup is to be renamed C:\Scripts\Archive, you must pass C:\Scripts\Archive as the complete folder name. Passing only the folder name Archive results in an Invalid path error.
Listing 11.9 contains a script that binds to the folder C:\Scripts and renames the folder C:\Script Repository. To carry out this task, the script must perform the following steps:
To limit data retrieval to a specified folder, a Where clause is included restricting the returned folders to those with the name C:\\Scripts. You must include both backslashes (\\) in the name.
Listing 11.9 Renaming Folders
|
|
Send us your feedback | « Previous | Next » |