Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
After you have connected to a special folder, you can enumerate the items within the folder the same way you enumerate the files found in a standard file system folder. This allows you to do such things as identify the administrative tools or the control panel applications that are installed on a computer.
For example, Listing 11.7 contains a script that lists the administrative tools installed on a computer. To carry out this task, the script must perform the following steps:
- Create a constant named ADMINISTRATIVE_TOOLS and set the value to &H2f&.
- Create an instance of the Shell object.
- Use the Namespace method to return a Folder object representing the Administrative Tools folder. This is done by passing the constant ADMINISTRATIVE_TOOLS as the parameter for the Namespace method.
- Use the Items method to return the folder items (the installed administrative tools) within the folder.
- Create a For Each loop to iterate all the folder items.
- Echo the item name.
Listing 11.7 Enumerating Installed Administrative Tools
1 2 3 4 5 6 7
| Const ADMINISTRATIVE_TOOLS = &H2f& Set objShell = CreateObject( "Shell.Application ") Set objFolder = objShell.Namespace(ADMINISTRATIVE_TOOLS) Set colTools = objFolder.Items For Each objTool in colTools Wscript.Echo objTool Next |
Send us your feedback | « Previous | Next » |