Export (0) Print
Expand All

WshShell Object

Microsoft® Windows® 2000 Scripting Guide

The shell is the component of Windows that presents users with an interface to the operating system and provides familiar elements of the Windows desktop experience, including Windows Explorer, the Start menu, shortcuts, and desktop themes.

The WshShell object gives your scripts the ability to work with the Windows shell. Your scripts can use the WshShell object to perform a number of system administration tasks, including running programs, reading from and writing to the registry, and creating shortcuts.

Figure 3.10 shows the properties and methods of the WshShell object.

Figure 3.10 WshShell Object Model

sas_wsh_110c

Accessing the WshShell Object

The WshShell object is a COM object, and using the following code statement can create an instance of the object:



Set objShell = WScript.CreateObject("WScript.Shell")

WshShell Capabilities

The WshShell object enables your script to automate tasks in a number of categories related to the Windows shell. Table 3.8 lists these categories along with the methods and properties of the WshShell object that your scripts can use to access this functionality.

Table 3.8 Capabilities Provided by the WshShell Object

Category

Method or Property

Running Programs

Run, Exec

Working with Special Folders

SpecialFolders

Working with Shortcuts

CreateShortcut

Working with Environment Variables

Environment, ExpandEnvironmentStrings

Working with the Event Log

LogEvent

Working with the Registry

RegRead, RegWrite, RegDelete

Sending Keystrokes to an Application

AppActivate, SendKeys

Obtaining a Scripts Current Directory

CurrentDirectory

Creating Timed Dialog Boxes

Popup

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