Monday, August 18, 2008

The WSH Object Model

The WshArguments Object

The WshArguments object is a collection object returned by the Arguments property of the WScript object

Example:

Dim oShell, oArgs

Set oArgs = WScript.Arguments

The WshEnvironment Object

The WshEnvironment object is a collection object returned by the Environment property of the WshShell object

Dim wsh, env

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

Set env = wsh.Environment


The WshNetwork object

The WshNetwork object represents network resources that are available to a client computer.

Dim oNet

Set oNet = WScript.CreateObject("WScript.Network")


The WshShell Object

The WshShell object provides access to a wide variety of shell services, such as registry access, access to environment variables and to the location of system folders, the ability to create shortcuts

Dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")


The WshShortcut Object

The WshShortcut object represents a shortcut—that is, a non-Internet link to a file or other resource on the local system or local network. A new or existing WshShortcut object is returned by the CreateShortcut method of the WshShell object,

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

Set oSCut = WshShell.CreateShortcut("Startup Script.lnk")


The WshSpecialFolders Object

WshSpecialFolders is a collection object that stores string variants that indicate the location of Windows system folders, like the Desktop folder of the Windows System folder. The collection is returned by the SpecialFolders property of the WshShell object,

Dim oShell, oSpFolders

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

Set oSpFolders = oShell.SpecialFolders


The WshUrlShortcut Object

The WshUrlShortcut object represents an Internet shortcut—an Internet link to an Internet resource. A new or an existing WshUrlShortcut object is returned by the CreateShortcut method of the WshShell object

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

Set oURL = WshShell.CreateShortcut("Favorite Website.url")