Export (0) Print
Expand All

Identifying Shell Object Verbs

Microsoft® Windows® 2000 Scripting Guide

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:

  1. 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.

  2. Create an instance of the Shell object.

  3. Use the Namespace method to return a Folder object representing the Recycle Bin.

  4. 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.

  5. 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.

  6. 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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft