WSH » Objects » wshshell

The WshShell object exposes some of the common shell functionalities of Microsoft Windows, making it easy to creates shortcuts, access the environment variables, run applications, access system registry, and more.

The WshShell object is not instantiated automatically upon script execution, hence it must be instantiated explicitly using CreateObject before it can be used.

Properties

Environment

Syntax: WshShell.Environment([strType])

The Environment property is read only and returns a WshEnvironment object.

SpecialFolders

Syntax: WshShell.SpecialFolders

The SpecialFolders property is read only and returns a WshSpecialFolders object.

Methods

AppActivate

Syntax: WshShell.AppActivate (strTitle)

The AppActivate method activates an application.

CreateShortcut

Syntax: WshShell.CreateShortcut (strPathName)

The CreateShortcut method creates and returns a WshShortcut object.

ExpandEnvironmentStrings

Syntax: WshShell.ExpandEnvironmentStrings (strString)

The ExpandEnvironmentStrings method expands the environment variables in a string and returns the resulting string.

LogEvent

Syntax: WshShell.LogEvent (intType, strMessage [,strTarget])

The LogEvent method logs an event in the Windows NT event log or WSH.log file.

Popup

Syntax: WshShell.Popup [,intSecondsToWait] [,strTitle] [,intType]

The Popup method displays a pop-up message box.

RegDelete

Syntax: WshShell.RegDelete (strName)

The RegDelete method removes a registry entry based on strName.

RegRead

Syntax: WshShell.RegRead (strName)

The RegRead method reads and returns a registry entry based on strName.

RegWrite

Syntax: WshShell.RegWrite (strName, varValue [,strType])

The RegWrite method writes a new entry into the registry.

Run

Syntax: WshShell.Run (strCommand [,intWindowStyle] [,bWaitOnReturn])

The Run method runs an application in a new process.

SendKeys

Syntax: WshShell.SendKeys (strKeyString)

The SendKeys method sends keystrokes to the active window. Similar to VB's SendKeys statement.