Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The Windows operating system features another COM object, the Shell object, that includes a number of properties and methods useful in managing file systems. Because the Shell object offers capabilities not available using either the FileSystemObject or WMI, you should also consider it when writing scripts for file system management.
The Shell is the portion of the Windows operating system tasked with managing and providing access to such things as:
The Shell namespace provides a way to manage these objects in a tree-structured hierarchy. At the top of this hierarchy is the Desktop; directly below the Desktop are virtual folders such as My Computer, My Network Places, and Recycle Bin. Within each of these virtual folders are other items (such as files, folders, and printers) that can also be managed using the Shell. If you start Windows Explorer, you see a visual representation of the Shell, as shown in Figure 11.1.
Figure 11.1 The Shell Namespace
The Shell Namespace
The Shell itself is composed largely of a series of COM objects, many of which can be accessed using VBScript. Included among these COM objects are folders. Within the Windows operating system, folders are individual COM objects that possess:
Folder objects and all the properties, items, and methods belonging to those objects can be accessed through the Shell object. The Shell object provides a way to programmatically reproduce all the features found in the Windows Shell. This means that file system management tasks which typically involve working with files and folders can be carried out using the Shell object.
Scripting the Shell object is not as intuitive as scripting with WMI or the FileSystemObject. For example, to bind to a file using a Shell object script, you must:
This is considerably more complicated than using the FileSystemObject or WMI. On the other hand, the Shell object does offer a number of capabilities not found in either WMI or the FileSystemObject, including the ability to:
In this chapter, the Shell object is used whenever it provides a unique capability not available using either WMI or the FileSystemObject.
Send us your feedback | « Previous | Next » |