Appendix G The Windows Script Host Object Model

Overview

This Appendix gives details about the Windows Script Host objects. Further details and examples can also be found in Chapter 12.

Windows Script Host has 14 objects outlined.

  • WScript Object:

This object provides access to most of the objects, methods , and properties contained in the WSH object model.

  • WshArguments Object:

This object gives the programmer access to the entire collection of command-line parameters in the order in which they were originally entered.

  • WshController Object:

This object exposes the method CreateScript() that creates a remote script process.

  • WshEnvironment Object:

This object gives the programmer access to the collection of Microsoft Windows system environment variables .

  • WshNamed Object:

This object provides access to the named command-line script arguments contained within the WshArguments object.

  • WshNetwork Object:

This object gives the programmer access to the shared resources on the network to which the host computer is connected.

  • WshRemote Object:

This object provides access to the remote script process.

  • WshRemoteError Object:

This object is used to expose the error information available when a remote script terminatesas a result of a script error.

  • WshScriptExec Object:

This object provides status and error information about a script.

  • WshShell Object:

This object is used to give the programmer access to the native Windows shell functionality.

  • WshShortcut Object:

This object allows the programmer to create shortcuts.

  • WshSpecialFolders Object:

This object is used to access Windows Special Folders.

  • WshUnnamed Object:

This object provides access to unnamed command-line script arguments within the WshArguments object.

  • WshUrlShortcut Object:

This allows the programmer to create a shortcut to an Internet resource.


The WScript Object

The root of the WSH object model is the WScript object. This object provides properties and methods that give the developer access to a variety of information, such as:

  • Name and path information for the script file being executed
  • Version of the Microsoft Scripting engines
  • Links to external objects
  • User interaction
  • The ability to delay or terminate script execution

WScript Properties

The WScript object has 11 properties:

  • Arguments Property
  • FullName Property
  • Interactive Property
  • Name Property
  • Path Property
  • ScriptFullName Property
  • ScriptName Property
  • StdErr Property
  • StdIn Property
  • StdOut Property
  • Version Property

WScript Methods

The WScript object has seven methods:

  • CreateObject Method
  • ConnectObject Method
  • DisconnectObject Method
  • Echo Method
  • GetObject Method
  • Quit Method
  • Sleep Method


The WshArguments Object

This object gives the programmer access to the entire collection of command-line parameters.

WshArguments Properties

The WshArguments object has four properties:

  • Item Property
  • Length Property
  • Named Property
  • Unnamed Property

WshArguments Methods

The WshArguments object has two methods:

  • Count Method
  • ShowUsage Method


WshController Object

This object is used to expose the method CreateScript() that creates a remote script process.

WshController Properties

The WshController object has no properties.

WshController Methods

The WshController object has one method:

  • CreateScript Method


WshEnvironment Object

This object provides access to the collection of Windows environment variables .

WshEnvironment Properties

The WshEnvironment object has two properties.

  • Item Property
  • Length Property

WshEnvironment Methods

The WshEnvironment object has two methods:

  • Count Method
  • Remove Method


WshNamed Object

This object is used to provide access to named arguments from the command line.

WshNamed Properties

The WshNamed object has two properties:

  • Item Property
  • Length Property

WshNamed Methods

The WshNamed object has two methods:

  • Count Method
  • Exists Method


The WshNetwork Object

The WshNetwork object provides access to the shared resources on the network to which the computer is connected.

WshNetwork Properties

The WshNetwork object has three properties:

  • ComputerName Property
  • UserDomain Property
  • UserName Property

WshNetwork Methods

The WshNetwork object has eight methods:

  • AddWindowsPrinterConnection Method
  • AddPrinterConnection Method
  • EnumNetworkDrives Method
  • EnumPrinterConnection Method
  • MapNetworkDrive Method
  • RemoveNetworkDrive Method
  • RemovePrinterConnection Method
  • SetDefaultPrinter Method


WshRemote Object

This object is used to provide access to the remote script process.

WshRemote Properties

The WshRemote object has two properties:

  • Status Property
  • Error Property

WshRemote Methods

The WshRemote object has two methods:

  • Execute Method
  • Terminate Method


WshRemoteError Object

This object provides access to the error information available when a remote script terminates because of a script error.

WshRemoteError Properties

The WshRemoteError object has six properties:

  • Description Property
  • Line Property
  • Character Property
  • SourceText Property
  • Source Property
  • Number Property

WshRemoteError Methods

The WshRemoteError object has one method:

  • WshRemote Object


WshScriptExec Object

The WshScriptExec object provides status information about a script run with Exec when used in conjunction with the StdIn , StdOut , and StdErr streams.

WshScriptExec Properties

The WshScriptExec object has four properties:

  • Status Property
  • StdOut Property
  • StdIn Property
  • StdErr Property

WshScriptExec Methods

The WshScriptExec object has one method:

  • Terminate Method


The WshShell Object

Windows Script Host provides a convenient way to gain access to system environment variables , create shortcuts, access Windows special folders such as the Windows Desktop, and add or remove entries from the registry. It is also possible to create more customized dialogs for user interaction by using features of the Shell object.

WshShell Properties

The WshShell object has three properties:

  • CurrentDirectory Property
  • Environment Property
  • SpecialFolders Property

WshShell Methods

  • The WshShell object has 11 methods:
  • AppActivate Method
  • CreateShortcut Method
  • ExpandEnvironmentStrings Method
  • LogEvent Method
  • Popup Method
  • RegDelete Method
  • RegRead Method
  • RegWrite Method
  • Run Method
  • SendKeys Method
  • Exec Method


The WshShortcut Object

The WshShortcut object allows you to create shortcuts using script.

WshShortcut Properties

The WshShortcut object has eight properties:

  • Arguments Property
  • Description Property
  • FullName Property
  • Hotkey Property
  • IconLocation Property
  • TargetPath Property
  • WindowStyle Property
  • WorkingDirectory Property

WshShortcut Methods

The WshShortcut object has one method:

  • Save Method


The WshSpecialFolders Object

The WshSpecialFolders object provides access to the collection of Windows special folders. The following special folders are available:

  • AllUsersDesktop
  • AllUsersStartMenu
  • AllUsersPrograms
  • AllUsersStartup
  • Desktop
  • Favorites
  • Fonts
  • MyDocuments
  • NetHood
  • PrintHood
  • Programs
  • Recent
  • SendTo
  • StartMenu
  • Startup
  • Templates

WshSpecialFolders Properties

The WshSpecialFolders object has one property:

  • Item Property

WshSpecialFolders Methods

The WshSpecialFolders object has one method:

  • Count Method


The WshUnnamed Object

The WshUnnamed object provides access to the unnamed arguments from the command line. The WshUnnamed object is a read-only collection that is returned by the Unnamed property of the WshArguments object. All individual argument values are retrieved from this collection using zero-based indexes.

There are three ways to access sets of command-line arguments:

  • Access the entire set of arguments with the WshArguments object.
  • Access the arguments that have names with the WshNamed object.
  • Access the arguments that have no names with the WshUnnamed object.

WshUnnamed Properties

The WshUnnamed object has two properties:

  • Item Property
  • Length Property

WshUnnamed Methods

The WshUnnamed object has one method:

  • Count Method


The WshUrlShortcut Object

The WshUrlShortcut object allows you to create shortcuts to Internet resource using script. The WshUrlShortcut object is a child object of the WshShell object. You must use the WshShell method CreateShortcut to create a WshUrlShortcut object.

WshUrlShortcut Properties

The WshUrlShortcut object has two properties:

  • FullName Property
  • TargetPath Property

WshUrlShortcut Methods

The WshUrlShortcut object has one method:

  • Save Method




VBScript Programmer's Reference
VBScript Programmers Reference
ISBN: 0470168080
EAN: 2147483647
Year: 2003
Pages: 242

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net