Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
One potential problem with carrying out actions using Shell object verbs is knowing which verbs, and thus which actions, are available to you. Fortunately, each Shell object exposes its verbs as a collection that can be enumerated programmatically. To identify the verbs for a particular Shell object, obtain a FolderItem object and then use the Verbs method to return a collection of all the verbs for that object. You can then list each verb in the collection.
Scripting Steps
Listing 11.28 contains a script that returns a list of all the Shell Object verbs that can be used with the Recycle Bin. To carry out this task, the script must perform the following steps:
- Create a constant named RECYCLE_BIN and set the value to &Ha&. This is the value used by the Namespace method to locate the Recycle Bin.
- Create an instance of the Shell object.
- Use the Namespace method to return a Folder object representing the Recycle Bin.
- Use the Self method to return a FolderItems object for the Recycle Bin. This is required because only FolderItems objects possess the Verbs method. This method returns a list of Shell object verbs that can be used with the Recycle Bin.
- Use the Verbs method to return a list of Shell object verbs that can be used with the Recycle Bin. Verbs are returned as an array, with the first verb assigned the index number 0.
- Create a For Each loop to echo the name of each verb.
Listing 11.28 Identifying Shell Object Verbs
1 2 3 4 5 6 7 8
| Const RECYCLE_BIN = &Ha& Set objShell = CreateObject( "Shell.Application ") Set objFolder = objShell.NameSpace(RECYCLE_BIN) Set objFolderItem = objFolder.Self Set colVerbs = objFolderItem.Verbs For Each objVerb in colVerbs Wscript.Echo objVerb Next |
Send us your feedback | « Previous | Next » |