Windows Scripting Host Tutorial

Microsoft® Windows® Scripting Host
Windows Scripting Host Tutorial 		Windows Scripting Host Reference


Introduction
Windows Scripting Host Tutorial
Next

The Microsoft® Windows® operating system Scripting Host is a language-independent scripting host for ActiveX® scripting engines on 32-bit Windows platforms. Windows Scripting Host will be integrated into Windows 98, Windows NT® Workstation operating system version 5.0, and Windows NT Server version 5.0.

Both Microsoft Visual Basic® development system Scripting Edition (VBScript) and Microsoft JScript® development system scripting engines are provided with Windows Scripting Host. Other software companies will provide ActiveX scripting engines for languages such as Perl, TCL, REXX, Python, and others. Windows Scripting Host can be run from either the Windows-based host (Wscript.exe), or the command-shell-based host (Cscript.exe).


This topic is under construction.

Advantages to .WSC files

Windows Scripting Host version 2.0 introduces a new file for running your scripts. The WSC file was designed to incorporate several key features to make it function better than the typical VBS and JS scripting files. There are six key benefits in using a WSC file:

  • Includes - incorporate functions that have already been written in a VBS or JS file.
  • Multiple Engines - use more than one scripting language per file.
  • Typelib support - add constants to your code.
  • Tools support - edit files with any XML editor
  • Enhanced Debugging -
  • Multiple Jobs in One File -

Includes

If you have created WSH files in the past you can still use them with a WSC file. This also allows you to have a library of functions that can be used by multiple WSC files.The following example shows a WSC file that includes a JS file, and a VBScript function that calls a function in the included file:

<? XML Version="1.0" ?>
<Job id="IncludeExample">
<Script language="JScript"
    SRC="FSO.JS"/>
<Script
    language="VBScript">

'Get the free space for drive C
s = GetFreeSpace("c")
Wscript.Echo s

</Script>
</Job>

Contents of fso.js

function GetFreeSpace(drvPath) {
var fs, d, s;
fs = new
    ActiveXObject("Scripting.FileSystemObject");
d = fs.GetDrive(fs.GetDriveName(drvPath);
s = "Drive " + drvPath + " - " ;
s += d.VolumeName +
    "<br>";
s += "Free
    Space: " + d.FreeSpace/1024 + " Kbytes";
Return s;
}

Multiple Engines

WSC files are not engine specific. A WSC file can contain any ActiveX compliant scripting engine, and can contain more than one at a time. Since one language may not have all the functionality that you are looking for, you can mix and match different languages together in one WSC file to get all the functionality you are looking for. The example below shows a WSC file that has both VBScript and PerlScript code:

<? XML Version="1.0" ?>
<job id="PERLandVBS">
<Script language=PerlScript RUNAT=Server>
sub PerlHello
{
my $str = @_[0];
$WScript->Echo($str);
}
</Script>
<Script language="VBScript">
WScript.Echo "Hello from VBScript"
PerlHello "Hello from PERLScript"
</Script>
</Job>

Typelib Support

MyComponent in the following example was developed with Visual Basic 5.0. MyComponent defines the constant MyError with the following statement.

Public Const MyError = "You are not using MyComponent correctly."

The type library is contained in mycomponent.lib, which you have installed in C:\MyComponent

<? XML Version="1.0" ?>
<Job id="IncludeExample">
<Reference
    URL="file:c:\mycomponent\mycompent.lib">
<Script language="VBScript">
Dim MyVar
Set MyVar =
    CreateObject("MyComponent.MyClass")
Currentreturn = MyVar.MyMethod
If Currentreturn = False
Response.Write(MyError)
End If
</Script>
</Job>

Tools Support

Since the WSC file is in XML format, any editor that supports XML can be used to edit WSC files.

Enhanced Debugging

<? XML Version="1.0" ?>
<job id="MyFirstJob">
<?Job validate="false" error="true" debug="true" ?>
<script language="VBScript">
Dim fs, d, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(drvPath))
s = "Drive " & UCase(drvPath) & " - "
s = s & d.VolumeName & vbCrLf
s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0)
s = s & " Kbytes"
Wscript.Echo s
</script>
</job>

Multiple Jobs in One File


Running Scripts Using Wscript.exe
Windows Scripting Host Tutorial
Previous
Next

Using Wscript.exe, you can run scripts under Windows in three ways:
  • Double-clicking files or icons. These can be files or icons listed in My Computer, Windows Explorer, the Find window, the Start menu, or on the Desktop.
  • Entering a script name at the Run command on the Start Menu. Press the Start button, select Run, and enter the full name of the script you want to run, including file extension and any necessary path information.
  • Entering Wscript.exe followed by a script name at the Run command. Press the Start button, select Run, and enter Wscript, followed by the full name and path of the script you want to run.
If you double-click a script file whose extension has not yet been associated with Wscript.exe, an Open With dialog box appears asking your what program you would like to use to open the file you double-clicked. After choosing Wscript, if you check the Always use this program to open this file check box, Wscript is registered as the default application for all files having the same extension as the one you double-clicked. For example, if you check this check box when you run Chart.vbs, Wscript.exe becomes the default application for all files having the .vbs extension.

Wscript.exe has a properties page associated with it that provides the following options:

Property | Function | CSCRIPT equivalent
Stop script after nn seconds. | Specifies a maximum number of seconds that a script can run (the default is no limit). | //T:nn
Display logo when scripts executed in a command console. Display a banner before running the script (this is the default the opposite is //nologo). //logo or
//nologo

By using the Wscript.exe Properties page, you can set global scripting options for all scripts that Wscript runs on the local machine. It is also possible to set options for individual scripts, using a .wsh file, as described in the next section.


Creating and Using .WSH Files
Windows Scripting Host Tutorial
Previous
Next
Creating .WSH Files to Record Script Options
You can record specific settings for each individual script you run by creating a control file for that script with a .wsh file extension.

A .wsh file is a text file that uses a format similar to that of .ini files. It is created automatically when you set the properties for a supported script file.

To create a .wsh file for a given script
  1. Right-click the given script file in Windows Explorer.
  2. Select Properties on the context menu that appears.
  3. Choose the settings you want for the script on the property page.
  4. Choose OK or Apply.
A .wsh file is automatically created using the same name as the script file that you right-clicked. A sample .wsh file might contain the following text:

[ScriptFile]
Path=C:\WINNT\Samples\WSH\showprop.vbs

[Options]
Timeout=0
DisplayLogo=1
BatchMode=0

The Path setting in the [ScriptFile] section identifies the script file that this .wsh file is associated with. The keys in the [Options] section correspond to settings in the Script tab within the Properties dialog box.
Using .WSH Files to Run Scripts
A .wsh file is analagous to the .pif files used to run older 16-bit applications. It can be treated as if it were an executable or batch file.

For example, suppose you have a script named Myscript.vbs for which you have created a .wsh file named Myscript.wsh. To run Myscript.vbs with the options recorded in Myscript.wsh, you can either double-click Myscript.wsh in Windows Explorer, or pass Myscript.wsh as a script argument to CScript.exe or WScript.exe. For example, you could enter the following command at the command prompt:

cscript Myscript.wsh

Administrators in particular will find .wsh files useful. By creating multiple .wsh files for a given script, an administrator can tailor the way that script runs to the needs of specific groups or even individuals within an organization.

The same logon script, for example, might serve two very different groups if invoked by two different .wsh files containing different settings and parameters.


Running Scripts Using Cscript.exe
® Windows Scripting Host Tutorial
Previous
Next
To use Cscript.exe, open a Command Prompt window and type a Cscript command line. CScript uses the following syntax:

cscript [script name] [host options...] [script options]

  • Script name is the name of the script file, complete with extension and any necessary path information, such as: d:\admin\vbscripts\chart.vbs.
  • Host options enable or disable various Windows Scripting Host features. Host options are always preceeded by two slashes (//).
  • Script options are passed to the script. Script parameters are always preceeded by only one slash (/).
Each parameter is optional; however, you cannot specify script options without specifying a script name. If you do not specify parameters, Cscript displays the Cscript syntax and the valid host parameters.

Cscript.exe supports the host parameters shown in the following table.

Parameter | Description
//I | Interactive Mode: allows display of user prompts and script errors (this is the default, and the opposite of //B).
//B | Batch Mode: suppresses command-line display of user prompts and script errors.
//T:nn | Enables time-out: the maximum number of seconds the script can run. The default is no limit. (See the text following this table for more information on this parameter.)
//logo | Displays a banner (default; opposite of //nologo).
//nologo | Prevents display of an execution banner at run time.
//H:Cscript or
//H:Wscript 		Registers Cscript.exe or Wscript.exe as the default application for running scripts. If neither is specified, Wscript.exe is assumed as the default.
//S | Saves the current command-line options for this user.
//? Shows command usage (same as with parameters).

The //T parameter prevents excessive execution of scripts; it does this by setting a timer. When execution time exceeds the specified value, Cscript interrupts the scripting engine using the IActiveScript::InterruptThread method and terminates the process.

A Cscript Example
Several sample scripts are installed when you install the final release of the Windows Scripting Host. These are also available for download at: http://www.microsoft.com/management/wsh.htm

Suppose, for the purposes of this example, that you have copied the Chart.vbs sample script to the following folder on your computer:

c:\sample scripts\chart.vbs

You can run the script using with and without a logo, as follows:
  1. Choose the MS-DOS® operating system Command Prompt from Programs on the Start menu.
  2. Enter the following commands at the command prompt (if your sample scripts are located in a different folder, these lines should be modified accordingly):
cscript //logo c:\"sample scripts"\chart.vbs
cscript //nologo c:\"sample scripts"\chart.vbs

When Windows Scripting Host ships with Windows NT 5.0, you will no longer need to provide the script file's extension. Instead, you can type the script name alone, or double-click the script in Windows Explorer.


Document Conventions
Windows Scripting Host Tutorial
Previous

Variable prefixes in parameter listings and code examples have the following meanings.

Prefix | Description
any | Any type
b | Boolean
int | Integer
nat | Natural number or nonnegative integer
obj | Object (Idispatch interface)
str | String

Scripting examples are written in the Microsoft Visual Basic Scripting Edition (VBScript).

Methods written in Microsoft Jscript are case-sensitive. In general, you should use the same case as the syntax examples shown in this document.

Parameters in brackets (for example, [anyValue]) are optional.


Windows Scripting Host Reference 		Windows Scripting Host Tutorial
Alphabetic
Keyword List
Elements

Methods

Objects

Properties

© 1998 Microsoft Corporation. All rights reserved.


<?Job?>
processing instruction
Windows Scripting Host Reference
Description
XML processing instruction specifying attributes for error handling.
Syntax
<?Job timeout="value"
    logo="flag" validate="flag" error="flag"
    debug="flag" ?>
Parameters

flag=A Boolean value: "true" or "false," 1 or 0, or "yes" or "no." The default value for all attributes is false.

timeoutvalue=Number of seconds after which the script will timeout

Remarks

In production most batch files will normally run silently. However, while you are developing your scriptlet file, you might find it useful to be notified about errors in the file. You can specify these types of error notification:

  • timeout Set this to the number of second after which the script will timeout
  • logo Set this to true if the cscript logo is to be displayed at runtime
  • validate Set this to true to perform XML validation. XML errors are reported when you register your scriptlet.
  • error Set this to true to allow error messages for syntax or run-time errors in the scriptlet file.
  • debug Set this to true to enable debugging. If this debugging is not enabled, you cannot launch the script debugger for a WSH batch file in any way.
Example
<?Job validate="false" error="true" debug="true" ?>


AddPrinterConnection Method
Windows Scripting Host Reference

See Also Applies To

Description

Maps the remote printer specified by strRemoteName to the local resource name strLocalName.

Syntax

object.AddPrinterConnection strLocalName, strRemoteName[,bUpdateProfile][,strUser][, strPassword]

Parameters
Part | Description
object | Always the WshNetwork object.
strLocalName | Local resource to map to.
strRemoteName | Remote printer to map.
bUpdateProfile | Optional. If bUpdateProfile is supplied and its value is TRUE, this mapping is stored in the user profile. strUser, strPassword.
strUser | Optional. If you are mapping a remote printer using the credentials of someone other than current user, you can specify strUser and strPassword.
strPassword | Optional. If you are mapping a remote printer using the credentials of someone other than current user, you can specify strUser and strPassword.

Remarks

The following example uses the AddPrinterConnection method to connect a network printer to LPT1:

Set WshNetwork = Wscript.CreateObject("Wscript.WshNetwork")
WshNetwork. AddPrinterConnection "LPT1", "\\Server\Print1"


Application Property
Windows Scripting Host Reference

Applies To

Description
The Application property provides the IDispatch interface on the Wscript object.
Syntax
Wscript.Application = objWscript


Arguments Property
Windows Scripting Host Reference

Applies To
Description
Returns a pointer to the WshArguments collection or identifies arguments for the shortcut.
Syntax
object.Arguments
Parameters
Part | Description
object | Wscript or WshShortcut object.
Remarks
The following example will display all command-line parameters:

    Set objArgs = Wscript.Arguments
    For I = 0 to objArgs.Count - 1
      Wscript.Echo objArgs(I)
    Next


ComputerName Property
Windows Scripting Host Reference

Applies To

Description
The ComputerName property provides a string representation of the computer name.
Syntax
WshNetwork.ComputerName = strComputerName


Count Property
Windows Scripting Host Reference

See Also Applies To
Description
Returns the number of enumerated items.
Syntax
object.Count
Parameters
Part | Description
object | WshArguments, WshEnvironment, WshCollection, or WshSpecialFolders


CreateObject Method
Windows Scripting Host Reference

See Also Applies To

Description
Creates an object specified by the strProgID parameter.
Syntax
object.CreateObject(strProgID[, strPrefix])
Parameters
Part | Description
object | Always the WScript object.
strProgID | The program ID of the object to create.
strPrefix | Optional.
Remarks
If the parameter strPrefix is specified, Windows Scripting Host connects the object's outgoing interface to the script file after creating the object. When the object fires an event, Windows Scripting Host calls a subroutine named strPrefix and the event name.

For example, if strPrefix is "MYOBJ_" and the object fires an event named "OnBegin," Windows Scripting Host calls the "MYOBJ_OnBegin" subroutine located in the script.

The following example uses the CreateObject method to create a WshNetwork object:

Set WshNetwork = Wscript. CreateObject("Wscript.WshNetwork" )


CreateShortcut Method
Windows Scripting Host Reference

See Also Applies To

Description
Creates an object reference to a shortcut or URLshortcut.
Syntax
object.CreateShortcut(strPathname)

Parameters

Part | Description
object | Always the WshShell object.
strPathname | Path and file name of the shortcut being created.
Remarks

The CreateShortcut method creates a WshShortcut object and returns it. If the shortcut title ends with ".URL," a WshURLShortcut object is created.

This following samples creates a shortcut to the currently executing script, and a URLshortcut to Microsoft.com:
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set oShellLink = WshShell. CreateShortcut("Current Script.lnk" )
oShellLink.TargetPath = Wscript.ScriptFullName
oShellLink.Save
Set oUrlLink = WshShell. CreateShortcut("Microsoft Web Site.URL" )
oUrlLink.TargetPath = "http://www.microsoft.com"
oUrlLink.Save


Description Property
Windows Scripting Host Reference

Applies To

Description
The Description property provides a description of a shortcut object.
Syntax
WshShortcut.Description = strDescription


DisconnectObject Method
Windows Scripting Host Reference

See Also Applies To

Description
Disconnects a previously connected object from Windows Scripting Host.
Syntax
object.DisconnectObject obj

Parameters

Part | Description
object | Always the Wscript object.
obj | Name of the object to be disconnected.
Remarks
If the specified object is not already connected to Windows Scripting Host, this method does nothing.
The following example instantiates a fictitious object and connects it to the script file. The script then calls the "SomeMethod" method on the object. If an error called "Event" occurs in the object, then the MyEvent_Event subroutine is called.
Set MyObject = Wscript.CreateObject("SomeObject", "MyEvent")
MyObject.SomeMethod
Sub MyEvent_Event(strName)
Wscript.Echo strName
End Sub
Wscript.DisconnectObject MyObject


Echo Method
Windows Scripting Host Reference

Applies To

Description
The Echo method displays parameters in a window (in Wscript.exe) or at the command prompt in a Command Prompt window (in Cscript.exe).

Parameters are delimited by one space. Under Cscript.exe, this method outputs a carriage-return/line feed pair (CR LF) after the last parameter displayed.
Syntax
Wscript.Echo [anyArg...]
Example
Wscript.Echo
Wscript.Echo 1, 2, 3
Wscript.Echo "Windows Scripting Host is cool."


EnumNetworkDrives Method
Windows Scripting Host Reference

See Also Applies To

Description
The EnumNetworkDrives method returns the current network drive mappings as a WshCollection object. Items in this collection are local names and remote names.
Syntax
WshNetwork.EnumNetworkDrive = objWshCollection
Example
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
Wscript.Echo oDrives.Item(0) = "Z:"
Wscript.Echo oDrives.Item(1) = "\\Server\Share"


EnumPrinterConnections Method
Windows Scripting Host Reference

See Also Applies To

Description
The EnumPrinterConnections method returns the current network drive mappings as a WshCollection object. Items in this collection are local names and remote names.
Syntax
WshNetwork.EnumPrinterConnections = objWshCollection
Example
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
Set oPrinters = WshNetwork.EnumPrinterConnections
Wscript.Echo oPrinters.Item(0) = "LPT1:"
Wscript.Echo oPrinters.Item(1) \\Server\Printer1"


Environment Property
Windows Scripting Host Reference

See Also Applies To

Description
The Environment property returns the WshEnvironment object.
Syntax
WshShell.Environment ( [strType]) = objWshEnvironment
Remarks
If strType specifies where the environment variable resides, possible values are "System," "User," "Volatile," and "Process." If strType is not supplied, this method retrieves the system environment variables in Windows NT or the process environment variables in Windows 95. For Windows 95, only "Process" is supported in the strType parameter. The following variables are provided with the Windows operating system. Scripts can also get environment variables that were set by other applications.

Name | Description
NUMBER_OF_PROCESSORS | Number of processors running on the machine
PROCESSOR_ARCHITECTURE | Processor type of the user's workstation
PROCESSOR_IDENTIFIER | Processor ID of the user's workstation
PROCESSOR_LEVEL | Processor level of the user's workstation
PROCESSOR_REVISION | Processor version of the user's workstation
OS | Operating system on the user's workstation
COMSPEC | Executable for command Command Prompt (typically cmd.exe)
HOMEDRIVE | Primary local drive (typically the C drive)
HOMEPATH | Default directory for users (on Windows NT this is typically \users\default
PATH | PATH environment variable
PATHEXT | Extensions for executable files (typically .com, .exe, .bat, or .cmd)
PROMPT | Command prompt (typically $P$G)
SYSTEMDRIVE | Local drive on which system directory resides (e.g., c:\)
SYSTEMROOT | System directory (e.g., c:\winnt). This is the same as WINDIR
WINDIR | System directory (e.g., c:\winnt). This is the same as SYSTEMROOT
TEMP | Directory for storing temporary files (e.g., c:\temp). User, Volatile
TMP | Directory for storing temporary files (e.g., c:\temp). User, Volatile
Example
' Retrieve the NUMBER_OF_PROCESSORS system environment variable
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
Wscript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")


ExpandEnvironmentStrings Method
Windows Scripting Host Reference

Applies To

Description
The ExpandEnvironmentStrings method expands the PROCESS environment variable in strString and returns the result string. Variables are enclosed by the "%" character.

The environment variable name is not case-sensitive.
Syntax
WshShell.ExpandEnvironmentStrings(strString) = strExpandedString
Example
MsgBox "Prompt is " & WshShell.ExpandEnviromentStrings("%PROMPT%")


FullName Property
Windows Scripting Host Reference

See Also Applies To
Description
Returns a string containing the full path to the host executable or shortcut object.
Syntax
object.FullName
Parameters
Part | Description
object | Wscript or WshUrlShortcut.


GetObject Method
Windows Scripting Host Reference

See Also Applies To

Description
The GetObject method retrieves an Automation object from a file, or an object specified by strProgID parameter. Use the GetObject method when there is a current instance of the object, or if you want to create the object from a file that is already loaded. If there is no current instance and you don't want the object started from a file that is already loaded, use the CreateObject method.
Syntax
Wscript.GetObject(strPathname [,strProgID] ], [strPrefix]) = objObject
Parameters
strPathname

The full path and the name of the file containing the object to retrieve. The parameter strPathname is required.

strProgID

A string representing the program identifier (ProgID) of the object.

strPrefix

If the parameter strPrefix is specified, Windows Scripting Host connects the object's outgoing interface to the script file after creating the object. When the object fires an event, Windows Scripting Host calls a subroutine named strPrefix and the event name.

For example, if strPrefix is "MYOBJ_" and the object fires an event named "OnBegin," Windows Scripting Host calls the "MYOBJ_OnBegin" subroutine located in the script.
Return
objObject

The Automation object retrieved.
Remarks
If an object has registered itself as a single-instance object (for example, the Word.Basic object in Microsoft Word 7.0), only one instance of the object is created, no matter how many times CreateObject is executed. In addition, with a single-instance object, GetObject always returns the same instance when called with the zero-length string syntax (""), and it causes an error if the path parameter is omitted. You can't use GetObject to obtain a reference to a Visual Basic class created with Visual Basic 4.0 or earlier.

GetObject works with all COM classes, independent of the language used to create the object.
Examples
Dim MyObject As Object
Set MyObject = GetObject(""C:\CAD\SCHEMA.CAD"")
= MyCAD.Application

When this code is executed, the application associated with the specified strPathname is started, and the object in the specified file is activated.

If strPathname is a zero-length string (""), GetObject returns a new object instance of the specified type. If the strPathname parameter is omitted entirely, GetObject returns a currently active object of the specified type. If no object of the specified type exists, an error occurs.

Some applications allow you to activate part of a file. To do this, add an exclamation point (!) to the end of the file name and follow it with a string that identifies the part of the file you want to activate. For information on how to create this string, see the documentation for the application that created the object. For example, in a drawing application you might have multiple layers to a drawing stored in a file. You could use the following code to activate a layer within a drawing file called schema.cad:

Set LayerObject = GetObject("C:\CAD\SCHEMA.CAD!Layer3")

If you do not specify the object's class, COM determines the application to start and the object to activate according to the file name you provide. Some files, however, may support more than one class of object. For example, a drawing might support three different types of objects: an application object, a drawing object, and a toolbar object, all of which are part of the same file. To specify which object in a file you want to activate, use the optional class parameter. For example:

Dim MyObject As Object
Set MyObject = GetObject("C:\DRAWINGS\SAMPLE.DRW", "FIGMENT.DRAWING")

In the above example, FIGMENT is the name of a drawing application and DRAWING is one of the object types it supports.

Once an object is activated, you reference it in code using the object variable you defined. In the above example, you access properties and methods of the new object using the object variable MyObject. For example:

MyObject.Line 9, 90
MyObject.InsertText 9, 100, "Hello, world."
MyObject.SaveAs "C:\DRAWINGS\SAMPLE.DRW"


Hotkey Property
Windows Scripting Host Reference

See Also Applies To

Description
The HotKey property provides the hotkey of a shortcut object. A hotkey is a keyboard shortcut to start or switch to a program.
Syntax
WshShortcut.HotKey = strHotKey
Remarks
BNF syntax of strHotKey is as follows:

Hotkey ::= modifier* keyname
modifier ::= "ALT+" | "CTRL+" | "SHIFT+" | "EXT+"
keyname ::= "A" .. "Z" |
"0".. "9" |
"Back" | "Tab" | "Clear" | "Return" |
"Escape" | "Space" | "Prior" | ...

Complete key names are found in WINUSER.H. Hotkey is case-insensitive.

Hotkeys can only activate shortcuts located on the Windows-based desktop or the Windows Start menu.
Example
Set WshShell = Wscript.CreateObject("Wscript.WshShell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oMyShortcut = WshShell.CreateShortcut(strDesktop & "\a_key.lnk")
OMyShortcut.TargetPath = "%windir%\notepad.exe"
oMyShortCut.Hotkey = "ALT+CTRL+F"
oMyShortCut.Save
Wscript.Echo oMyShortCut.HotKey = "Alt+Ctrl+F"


IconLocation Property
Windows Scripting Host Reference

Applies To

Description
The IconLocation property provides the icon location of a shortcut object. The format of the icon location should be "Path,index".
Syntax
WshShortcut.IconLocation = strIconLocation


Item Property
Windows Scripting Host Reference

See Also Applies To

Description

The Item property provides the natIndexth enumerated item as a string. It is the default property.

Syntax

WshCollection(natIndex) = strEnumeratedItem
WshCollection.Item(natIndex) = strEnumeratedItem

Example

Set WshNetwork = Wscript.CreateObject("Wscript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
Wscript.Echo oDrives.Item(0) = " "Z:"
Wscript.Echo oDrives.Item(1) = "\\Server\Share"

Description

The Item property contains the natIndexth command-line parameter as a string. It is the default property.

Syntax

Arguments(natIndex)
object.Item(natIndex) = strArgument

Example

Set oArgs = Wscript.Arguments.
Wscript.Echo oArgs(0)
Wscript.Echo oArgs.Item(0)

Description

The Item property sets or returns the value for the strName environment variable. It is the default property.

Syntax

WshEnvironment.Item("strName") = strValue
WshEnvironment("strName") = strValue

Example

' Get the value of NUMBER_OF_PROCESSORS environment variable
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
Wscript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")

' Set the value of EXAMPLE volatile environment variable to A_VALUE
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshEnv = WshShell.Environment("VOLATILE")
WshEnv("EXAMPLE")= "A_VALUE"

' List all system environment variables
Set WshShell = Wscript.CreateObject("Wscript.Shell")
For Each strVarName In WshShell.Environment("SYSTEM")
MsgBox strVarName
Next

Description

The Item property returns the full path for the special folder specified by strFolderName. It is the default property.

Syntax

WshShell.SpecialFolders.Item("strFolderName") = strFolderPath
WshShell.SpecialFolders("strFolderName") = strFolderPath

Remarks

WshShell.SpecialFolders("strFolderName") returns NULL if the requested folder (strFolderName) is not available. For example, Windows 95 does not have an AllUsersDesktop folder and returns NULL if strFolderName = AllUsersDesktop

The following special folders are provided with the Windows 95 and Windows NT 4.0 operating systems:

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

Example

' This fragment returns the full path for the Windows Desktop folder
Set WshShell = Wscript.CreateObject("Wscript.Shell")
StrMyDesktop = WshShell.SpecialFolders("Desktop")

' List all special folders
For Each strFolder In WshShell.SpecialFolders
MsgBox strFolder
Next


<job> Element
Windows Scripting Host Reference
Description
Allows for multiple jobs to be defined in a single file. This is an enclosing tag so that every tag within the Job tag will apply to that job.
Syntax
<job ID=JobID>
Parameters
JobID - The unique (to the file) identifier of the job


Length Property
Windows Scripting Host Reference

See Also Applies To
Description
Returns the number of enumerated items.
Syntax
object.length
Parameters
Part | Description
object | WshArguments, WshCollection, WshEnvironment, or WshSpecialFolders
Remarks
This property provides the same functionality as the Count property and is provided for compatibility with Microsoft JScript.


MapNetworkDrive Method
Windows Scripting Host Reference

See Also Applies To

Description
The MapNetworkDrive method maps the share point specified by strRemoteName to the local resource name strLocalName.
Syntax
WshNetwork.MapNetworkDrive strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword]
Parameters
strLocalName

Local resource name to map to.

strRemoteName

Remote share to map.

bUpdateProfile

If bUpdateProfile is supplied and its value is TRUE, this mapping is stored in the user profile.

strUser, strPassword

If you are mapping the share point using the credentials of someone other than current user, you can specify strUser and strPassword.
Example
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
WshNetwork.MapNetworkDrive "Z:", "\\Server\Share"


Name Property
Windows Scripting Host Reference

Applies To

Description
The Name property provides a string containing the friendly name of the Wscript object. This is the default property.
Syntax
Wscript.Name = strName
Example
Wscript.Name = Windows Scripting Host
Wscript = Windows Scripting Host


<object> Element
Windows Scripting Host Reference
Description

XML element used in scriptlet files to define objects that can be referenced by script.

Syntax

<object id="objID"
    [classid="clsid:GUID" |
    progid="progID"]/>

Parameters
Part | Description
objID

A name by which the object can be referenced in your script. Object ID values must begin with a letter and can include letters, digits, and underscores (_). The object ID must be unique throughout the scope of the scriptlet. For example, if you specify the name CObj, you can reference the object in your script this way:

x = CObj.Prop1
GUID

(Optional) A reference to the class ID (GUID) under which the object has been registered. Use "clsid:" followed by the class ID (without curly brackets). Either a classid or a progid attribute must be specified. For example:

classid="clsid:2154c700-9253-11d1-a3ac-0aa0044eb5f"
progID | (Optional) The program ID of the object, which can be specified as an alternative to the class ID. Either a classid or a progid attribute must be specified.
Remarks

The <object> element provides a way to expose objects globally for use in scripting within the scriptlet without having to use function such as CreateObject(). Using an <object> element makes the object available with global scope, and allows scripting tools to provide statement completion for the object's members.


Popup Method
Windows Scripting Host Reference

See Also Applies To

Description
The Popup method displays a popup message box window that contains the message contained in strText. The window title of this message box is specified by strTitle. If strTitle is omitted, the window title is "Windows Scripting Host."
Syntax
WshShell.Popup(strText, [natSecondsToWait], [strTitle], [natType]) = intButton
Remarks
If natSecondsToWait is supplied and its value is greater than zero, the message box window will be closed after natSecondsToWait seconds.

The meaning of natType is the same as in the Microsoft Win32® application programming interface MessageBox function. The following table shows the value and its meaning in natType. You can combine values in the following tables.

Button Types

Value | Description
0 | Show [OK] button
1 | Show [OK] and [Cancel] buttons
2 | Show [Abort], [Retry] and [Ignore] buttons
3 | Show [Yes], [No] and [Cancel] buttons
4 | Show [Yes] and [No] buttons
5 | Show [Retry] and [Cancel] buttons

Icon Types

Value | Description
16 | Show "Stop Mark" icon
32 | Show "Question Mark" icon
48 | Show "Exclamation Mark" icon
64 | Show "Information Mark" icon

The preceding two tables do not cover all values for natType. For a complete list, see the Win32 documentation.

The return value intButton denotes the number of the button that the user clicked. If the user does not click a button before natSecondsToWait seconds, intButton is set to -1.

Value | Description
1 | [OK] button
2 | [Cancel] button
3 | [Abort] button
4 | [Retry] button
5 | [Ignore] button
6 | [Yes] button
7 | [No] button
Example
Set WshShell = Wscript.CreateObject("Wscript.Shell") WshShell.Popup "Where do you want to go today?"


Quit Method
Windows Scripting Host Reference

Applies To

Description
The Quit method quits execution with a specified error code.
Syntax
Wscript.Quit [intErrorCode]
Parameters
intErrorCode

If this parameter is included, Wscript returns it as the process exit code. Otherwise, if intErrorCode is omitted, Wscript returns zero (0) as the process exit code.
Example
Wscript.Quit(1)


<reference> Element
Windows Scripting Host Reference
Description

XML element used in scriptlet files to include a reference to an external type library.

Syntax

<reference[object="progID"|guid="typelibGUID"] [version="version"]>

Parameters
Part | Description
progID

The program ID from which the type library can be derived, which can include a version number (for example, ADO.Recordset.2.0). This can include the explicit program ID of a type library, or the program ID of the executable (such as a .DLL) that incorporates the type library. If you use the object attribute, you do not need to specify a version attribute, because the version can be inferred from the program ID.

If the object attribute is specified, you cannot also specify a guid attribute.

typelibGUID | The GUID of the type library to reference. If the guid attribute is specified, you cannot also specify an object attribute.
version | (Optional) The version number of the type library to use. It must be in the form <major version>[.<minor version>]. If a version is not specified, the default version is 1.0. If the object attribute is used to specify the type library and the version is not specified, the version is derived from the Registry key for the specified program ID. If none can be found, the default is 1.0.
Remarks

Referencing a type library in your scriptlet allows you to use constants defined in the type library in scripts. The <reference> element looks up and makes available the type library associated with a specific program ID or type library name. Type library information can be available in .tlb, .olb, or .dll files.

The <reference> element should appear inside the <scriptlet> element. If there is more than one scriptlet in the package, the type library applies to only the scriptlet in whose <scriptlet> element it is declared.

Error Values

The WSH runtime can return one of the following typelib related error messages.

Error | Description | Reason
WSH 0201 | Invalid type library specification. The TYPELIB tag contains an invalid type library specification. | Typelib is corrupt
WSH 0202 | Type library cannot be loaded. Windows Scripting Host cannot load the type library specified in theTYPELIB tag. | Can't find/load the typelib
WSH 0203 | Type library cannot be wrapped. Windows Scripting Host cannot create a Type Library Wrapper object from the type libraries specified in the TYPELIB tag. | Anything else!


RegDelete Method
Windows Scripting Host Reference

See Also Applies To

Description
The RegDelete method deletes from the registry the key or value named strName.
Syntax
WshShell.RegDelete strName
Parameters
strName

If strName ends with a backslash character (\), this method deletes the key instead of the value. The strName parameter must begin with one of following root key names:

Short | Long
HKCU | HKEY_CURRENT_USER
HKLM | HKEY_LOCAL_MACHINE
HKCR | HKEY_CLASSES_ROOT
HKEY_USERS
HKEY_CURRENT_CONFIG
Example
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.RegDelete "HKCU\ScriptEngine\Value" ' Delete value "Value"
WshShell.RegDelete "HKCU\ScriptEngine\Key\" ' Delete key "Key"


RegRead Method
Windows Scripting Host Reference

See Also Applies To

Description
The RegRead method returns the registry key or value named by strName.
Syntax
WshShell.RegRead(strName) = strValue
Parameters
strName

If strName ends with the backslash character (\), this method returns the key instead of the value. StrName must begin with one of following root key names:

Short | Long
HKCU | HKEY_CURRENT_USER
HKLM | HKEY_LOCAL_MACHINE
HKCR | HKEY_CLASSES_ROOT
HKEY_USERS
HKEY_CURRENT_CONFIG
Remarks
The RegRead method supports only REG_SZ, REG_EXPAND_SZ, REG_DWORD, REG_BINARY, and REG_MULTI_SZ data types. If the registry has other data types, RegRead returns DISP_E_TYPEMISMATCH.
Example
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.RegRead("HKCU\ScriptEngine\Val") ' Read from value "Val"
WshShell.RegRead("HKCU\ScriptEngine\Key\") ' Read from key "Key"


RegWrite Method
Windows Scripting Host Reference

See Also Applies To

Description
The RegWrite method sets the registry key or value named by strName.
Syntax
WshShell.RegWrite strName, anyValue, [strType]
Parameters
strName

If strName ends with the backslash character (\), this method returns the key instead of the value. StrName must begin with one of following root key names:

Short | Long
HKCU | HKEY_CURRENT_USER
HKLM | HKEY_LOCAL_MACHINE
HKCR | HKEY_CLASSES_ROOT
HKEY_USERS
HKEY_CURRENT_CONFIG
Remarks
RegWrite supports strType as REG_SZ, REG_EXPAND_SZ, REG_DWORD and REG_BINARY. If another data type is passed as strType, RegWrite returns E_INVALIDARG.

RegWrite automatically converts anyValue to a string when strType is REG_SZ or REG_EXPAND_SZ. If strType is REG_DWORD, anyValue is converted to an integer. If strType is REG_BINARY, anyValue must be an integer.
Example
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.RegWrite "HKCU\ScriptEngine\Value", "Some string value"
WshShell.RegWrite "HKCU\ScriptEngine\Key\", 1 "REG_DWORD"


Remove Method
Windows Scripting Host Reference

See Also Applies To

Description
The Remove method deletes the environment variable specified by strName.
Syntax
WshEnvironment.Remove(strName)
Example
' Delete the EXAMPLE volatile environment variable
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Environment("VOLATILE").Remove("EXAMPLE")

' Delete multiple variables
Set WshUsrEnv = Wscript.Environment("User")
WshUsrEnv.Remove("EXAMPLE_1")
WshUsrEnv.Remove("EXAMPLE_2")
WshUsrEnv.Remove("EXAMPLE_3")
WshUsrEnv.Remove("EXAMPLE_4")


RemoveNetworkDrive Method
Windows Scripting Host Reference

See Also Applies To

Description
The RemoveNetworkDrive method removes the current resource connection denoted by strName.
Syntax
WshNetwork.RemoveNetworkDrive strName, [bForce], [bUpdateProfile]
Parameters
strName

The strName parameter can be either a local name or a remote name, depending on how the drive is mapped. If the drive has a mapping between a local name (drive letter) and a remote name, then strName must be set to the local name. If the network path does not have a local name (drive letter) mapping, then strName must be set to the remote name.

bForce

If bForce is supplied and its value is TRUE, this method removes the connections whether the resource is used or not.

bUpdateProfile

If bUpdateProfile is supplied and its value is TRUE, this mapping is stored in the user profile.
Example
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
' Local name mapped to remote share
WshNetwork.MapNetworkDrive "Z:", "\\Server\Share"
WshNetwork.RemoveNetworkDrive "Z:"
' No local name mapping, such as:
' NET USE \\Server\ShareWshNetwork.RemoveNetworkDrive "\\Server\Share"
WshNetwork.MapNetworkDrive "\\Server\Share"
WshNetwork.RemoveNetworkDrive "\\Server\Share"


RemovePrinterConnection Method
Windows Scripting Host Reference

See Also Applies To

Description
The RemovePrinterConnection method removes the current resource connection denoted by strName.
Syntax
WshNetwork.RemovePrinterConnection strName, [bForce], [bUpdateProfile]
Parameters
strName

The strName parameter can be either a local name or a remote name, depending on how the printer is connected. If the printer has a mapping between a local name (for examle, LPT1) and a remote name, then strName must be set to the local name. If the network path does not have a local name mapping, then strName must be set to the remote name.

bForce

If bForce is supplied and its value is TRUE, this method removes the connections whether the resource is used or not.

bUpdateProfile

If bUpdateProfile is supplied and its value is TRUE, this mapping is stored in the user profile.
Example
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
' Local name mapped to remote share
WshNetwork.RemovePrinterConnection "LPT1:"
' No local name mapping. e.g. NET USE "\\Server\Printer1"
WshNetwork.RemovePrinterConnection "\\Server\Printer1"


Run Method
Windows Scripting Host Reference

Applies To

Description
The Run method creates a new process that executes strCommand with window style intWindowStyle.
Syntax
WshShell.Run (strCommand, [intWindowStype], [bWaitOnReturn])
Parameters
sstrCommand

Environment variables within the strCommand parameter are automatically expanded.

bWaitOnReturn

If bWaitOnReturn is not specified or FALSE, this method immediately returns to script execution rather than waiting on the process termination.

If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application.

If bWaitOnReturn is not specified or is FALSE, Run returns an error code of 0 (zero).
Example
' This fragment launches Notepad with the current executed script
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run ("notepad " & Wscript.ScriptFullName)
WshShell.Run ("%windir%\notepad" & Wscript.ScriptFullName)

' This fragment returns the error code from the executed application
Return = WshShell.Run("notepad " & Wscript.ScriptFullName, 1, TRUE)


Save Method
Windows Scripting Host Reference

Applies To

Description
The Save method saves the shortcut object to the location specified by the FullName property.
Syntax
WshShortcut.Save
Description
The Save method saves a shortcut to the location specified by the FullName property.
Syntax
WshUrlShortcut.Save


<script> Element
Windows Scripting Host Reference
Description

XML element containing script to define the scriptlet's behavior.

Syntax
<script language="language">
script here
</script>
Parameters

language

The name of the scripting language used in the scriptlet file, such as VBScript or JScript.


ScriptFullName Property
Windows Scripting Host Reference

See Also Applies To

Description
The ScriptFullName property provides the full path to the script being run by the Windows Scripting Host.
Syntax
Wscript.ScriptFullName = strScriptFullName
Example
Wscript.ScriptFullName = C:\Users\Default\WSH\Sample.VBS


SetDefaultPrinter Method
Windows Scripting Host Reference

See Also Applies To

Description
The SetDefaultPrinter method sets default print to the remote printer specified by strPrinterName.
Syntax
The SetDefaultPrinter method sets default print to the remote printer specified by strPrinterName.
Parameters
strPrinterName

Remote printer name to set as default, such as "\\Server\Printer1". Note that strPrinterName cannot be a local name such as "LPT1:".


SpecialFolders Property
Windows Scripting Host Reference

See Also Applies To

Description
The SpecialFolders property provides the WshSpecialFolders object for accessing Windows shell folders such as the desktop folder, start menu folder, and personal document folder.
Syntax
WshShell.SpecialFolders = objWshSpecialFolders
Example
' This code fragment shows how to access the desktop folder
Set WshShell = Wscript.CreateObject("Wscript.Shell")
MsgBox "Your desktop is " & WshShell.SpecialFolders("Desktop")


TargetPath Property
Windows Scripting Host Reference

Applies To
Description
Returns the target path of a shortcut object.
Syntax
object.TargetPath
Parameters
Part | Description
object | WshShortcut or WshUrlShortcut


UserDomain Property
Windows Scripting Host Reference

Applies To

Description
The UserDomain property provides a string representation of the user domain name.
Syntax
WshNetwork.UserDomain = strDomain


UserName Property
Windows Scripting Host Reference

Applies To

Description
The UserName property provides a string representation of the user name.
Syntax
WshNetwork.UserName = strName


Version Property
Windows Scripting Host Reference

Applies To

Description
The Version property provides a version string for the Windows Scripting Host.
Syntax
Wscript.Version = strVersion
Example
Wscript.Version = 5.0


WindowStyle Property
Windows Scripting Host Reference

Applies To

Description
The WindowStyle property provides the window style of a shortcut object.
Syntax
WshShortcut.WindowStyle = natWindowStyle


Wscript Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Exposed to scripting engine as "Wscript."
Remarks
ProgID | N/A
Filename | Wscript.exe or Cscript.exe
CLSID | 60254CA2-953b-11CF-8C96-00AA00B8708C
IID | 60254CA1-953b-11CF-8C96-00AA00B8708C


WshArguments Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Not exposed; accessed through the Wscript.Arguments property.
Remarks
ProgID | N/A
Filename | Wscript.Exe or Cscript.Exe
CLSID | 60254CA4-953b-11CF-8C96-00AA00B8708C
IID | 60254CA3-953b-11CF-8C96-00AA00B8708C


WshCollection Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Not exposed; accessed through WshNetwork.enumNetworkDrives method or WshNetwork.EnumPrinterConnections method.
Remarks
ProgID | N/A
Filename | WSHom.Ocx
CLSID | F935DC24-1CF0-11d0-ADB9-00C04FD58A0B
IID | F935DC23-1CF0-11d0-ADB9-00C04FD58A0B


WshEnvironment Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Not exposed; accessed through WshShell.Environment property.
Remarks
ProgID | N/A
Filename | WSHom.Ocx
CLSID
IID


WshNetwork Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Automation Object
Remarks
ProgID | Wscript.WshNetwork
Filename | WSHom.Ocx
CLSID | F935DC26-1CF0-11d0-ADB9-00C04FD58A0B
IID | F935DC25-1CF0-11d0-ADB9-00C04FD58A0B


WshShell Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Automation Object
Remarks
ProgID | Wscript.WshShell
Filename | WSHom.Ocx
CLSID | F935DC22-1CF0-11d0-ADB9-00C04FD58A0B
IID | F935DC21-1CF0-11d0-ADB9-00C04FD58A0B


WshShortcut Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Not exposed; accessed through WshShell.CreateShortcut Method.
Remarks
ProgID | N/A
Filename | WSHom.Ocx
CLSID | F935DC28-1CF0-11d0-ADB9-00C04FD58A0B
IID | F935DC27-1CF0-11d0-ADB9-00C04FD58A0B


WshUrlShortcut Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Not exposed; accessed through WshShell.CreateShortcut method.
Remarks
ProgID | N/A
Filename | WSHom.Ocx
CLSID
IID


Path Property
Windows Scripting Host Reference

See Also Applies To

Description
The Wscript.Path property provides a string containing the name of the directory where Wscript.Exe or Cscript.Exe resides.
Syntax
Wscript.Path = strPath
Example
Wscript.Path = C:\WinNT\System32


ScriptName Property
Windows Scripting Host Reference

See Also Applies To

Description
The ScriptName property provides the file name of the script being run by the Windows Scripting Host.
Syntax
Wscript.ScriptName = strScriptName
Example
Wscript.ScriptName = Sample.VBS


WorkingDirectory Property
Windows Scripting Host Reference

Applies To

Description
The WorkingDirectory property provides the working directory of a shortcut object.
Syntax
WshShortcut.WorkingDirectory = strWorkingDirectory


vbscopy

Copyright

Information in this document is subject to change without notice. The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted. Complying with all applicable copyright laws is the responsibility of the user. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

© 1991-1998 Microsoft Corporation. All rights reserved.

Microsoft, MS, MS-DOS, ActiveX, JScript, Microsoft Press, Visual Basic, Windows, Windows NT, Win32, and Win32s are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries.

Other product and company names mentioned herein may be the trademarks of their respective owners.


AddPrinterConnection Method
Applies To 		Windows Scripting Host Reference

WshNetwork Object


AddPrinterConnection Method
See Also 		Windows Scripting Host Reference

EnumPrinterConnections Method
RemovePrinterConnection Method
SetDefaultPrinter Method
WshCollection Object


CreateObject Method
Applies To 		Windows Scripting Host Reference

Wscript Object


CreateObject Method
See Also 		Windows Scripting Host Reference

GetObject Method
DisconnectObject Method


CreateShortcut Method
Applies To 		Windows Scripting Host Reference

WshShell Object


CreateShortcut Method
See Also 		Windows Scripting Host Reference

WshShortcut Object
WshUrlShortcut Object


DisconnectObject Method
Applies To 		Windows Scripting Host Reference

Wscript Object


DisconnectObject Method
See Also 		Windows Scripting Host Reference

CreateObject Method
GetObject Method


Echo Method
Applies To 		Windows Scripting Host Reference

Wscript Object


EnumNetworkDrives Method
Applies To 		Windows Scripting Host Reference

WshNetwork Object


EnumNetworkDrives Method
See Also 		Windows Scripting Host Reference

MapNetworkDrive Method
RemoveNetworkDrive Method
WshCollection Object


EnumPrinterConnections Method
Applies To 		Windows Scripting Host Reference

WshNetwork Object


EnumPrinterConnections Method
See Also 		Windows Scripting Host Reference

AddPrinterConnection Method
RemovePrinterConnection Method
SetDefaultPrinter Method
WshCollection Object


ExpandEnvironmentStrings Method
Applies To 		Windows Scripting Host Reference

WshShell Object


GetObject Method
Applies To 		Windows Scripting Host Reference

Wscript Object


GetObject Method
See Also 		Windows Scripting Host Reference

CreateObject Method
DisconnectObject Method


MapNetworkDrive Method
Applies To 		Windows Scripting Host Reference

WshNetwork Object


MapNetworkDrive Method
See Also 		Windows Scripting Host Reference

EnumNetworkDrives Method
RemoveNetworkDrive Method
WshCollection Object


Popup Method
Applies To 		Windows Scripting Host Reference

WshShell Object


Popup Method
See Also 		Windows Scripting Host Reference

Echo Method


Quit Method
Applies To 		Windows Scripting Host Reference

Wscript Object


RegDelete Method
Applies To 		Windows Scripting Host Reference

WshShell Object


RegDelete Method
See Also 		Windows Scripting Host Reference

RegRead Method
RegWrite Method


RegRead Method
Applies To 		Windows Scripting Host Reference

WshShell Object


RegRead Method
See Also 		Windows Scripting Host Reference

RegDelete Method
RegWrite Method


RegWrite Method
Applies To 		Windows Scripting Host Reference

WshShell Object


RegWrite Method
See Also 		Windows Scripting Host Reference

RegDelete Method
RegRead Method


Remove Method
Applies To 		Windows Scripting Host Reference

WshEnvironment Object


Remove Method
See Also 		Windows Scripting Host Reference

Environment Property


RemoveNetworkDrive Method
Applies To 		Windows Scripting Host Reference

WshNetwork Object


RemoveNetworkDrive Method
See Also 		Windows Scripting Host Reference

EnumNetworkDrives Method
MapNetworkDrive Method
WshCollection Object


RemovePrinterConnection Method
Applies To 		Windows Scripting Host Reference

WshNetwork Object


RemovePrinterConnection Method
See Also 		Windows Scripting Host Reference

AddPrinterConnection Method
EnumPrinterConnections Method
SetDefaultPrinter Method
WshCollection Object


Run Method
Applies To 		Windows Scripting Host Reference

WshShell Object


Save Method
Applies To 		Windows Scripting Host Reference

WshShortcut Object
WshUrlShortcut Object


SetDefaultPrinter Method
Applies To 		Windows Scripting Host Reference

WshNetwork Object


SetDefaultPrinter Method
See Also 		Windows Scripting Host Reference

AddPrinterConnection Method
EnumPrinterConnections Method
RemovePrinterConnection Method
WshCollection Object


Wscript Object
Methods 		Windows Scripting Host Reference

CreateObject Method
DisconnectObject Method
Echo Method
GetObject Method
Quit Method


Wscript Object
Properties 		Windows Scripting Host Reference

Application Property
Arguments Property
FullName Property
Name Property
Path Property
ScriptFullName Property
ScriptName Property
Version Property


WshArguments Object
See Also 		Windows Scripting Host Reference

Arguments Property


WshArguments Object
Properties 		Windows Scripting Host Reference

Item Property
Count Property
Length Property


WshCollection Object
See Also 		Windows Scripting Host Reference

EnumNetworkDrives Property
EnumPrinterConnection Property


WshCollection Object
Properties 		Windows Scripting Host Reference

Item Property
Count Property
Length Property


WshEnvironment Object
See Also 		Windows Scripting Host Reference

Environment Property


WshEnvironment Object
Methods 		Windows Scripting Host Reference

Remove Method


WshEnvironment Object
Properties 		Windows Scripting Host Reference

Item Property
Count Property
Length Property


WshNetwork Object
See Also 		Windows Scripting Host Reference

WshCollection Object


WshNetwork Object
Methods 		Windows Scripting Host Reference

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


WshNetwork Object
Properties 		Windows Scripting Host Reference

ComputerName Property
UserDomain Property
UserName Property


WshShell Object
Methods 		Windows Scripting Host Reference

CreateShortcut Method
ExpandEnvironmentStrings Method
Popup Method
RegDelete Method
RegRead Method
RegWrite Method
Run Method


WshShell Object
Properties 		Windows Scripting Host Reference

Environment Property
SpecialFolders Property


WshShortcut Object
See Also 		Windows Scripting Host Reference

CreateShortcut Method


WshShortcut Object
Methods 		Windows Scripting Host Reference

Save Method


WshShortcut Object
Properties 		Windows Scripting Host Reference

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


WshSpecialFolders Object
Windows Scripting Host Reference

See Also Properties Methods

Description
Not exposed; accessed through WshShell.Specialfolders property.
Remarks
ProgID | N/A
Filename | WSHom.Ocx
CLSID
IID


WshSpecialFolders Object
See Also 		Windows Scripting Host Reference

SpecialFolders Property


WshSpecialFolders Object
Properties 		Windows Scripting Host Reference

Item Property
Count Property
Length Property


WshUrlShortcut Object
See Also 		Windows Scripting Host Reference

CreateShortcut Method


WshUrlShortcut Object
Methods 		Windows Scripting Host Reference

Save Method


WshUrlShortcut Object
Properties 		Windows Scripting Host Reference

FullName Property
TargetPath Property


Application Property
Applies To 		Windows Scripting Host Reference

Wscript Object


Arguments Property
Applies To 		Windows Scripting Host Reference

WshShortcut Object
Wscript Object
WshArguments Object


ComputerName Property
Applies To 		Windows Scripting Host Reference

WshNetwork Object


Count Property
Applies To 		Windows Scripting Host Reference

WshEnvironment Object
WshCollection Object
WshSpecialFolders Object
WshArguments Object


Count Property
See Also 		Windows Scripting Host Reference

Arguments Property
Length Property


Description Property
Applies To 		Windows Scripting Host Reference

WshShortcut Object


Environment Property
Applies To 		Windows Scripting Host Reference

WshShell Object
WshEnvironment Object


Environment Property
See Also 		Windows Scripting Host Reference

WshEnvironment Object


FullName Property
Applies To 		Windows Scripting Host Reference

Wscript Object
WshUrlShortcut Object


FullName Property
See Also 		Windows Scripting Host Reference

Path Property


Hotkey Property
Applies To 		Windows Scripting Host Reference

WshShortcut Object


Hotkey Property
See Also 		Windows Scripting Host Reference

WshSpecialFolders Object


IconLocation Property
Applies To 		Windows Scripting Host Reference

WshShortcut Object


Item Property
Applies To 		Windows Scripting Host Reference

WshSpecialFolders Object
WshCollection Object
WshEnvironment Object
WshArguments Object


Item Property
See Also 		Windows Scripting Host Reference

Arguments Property
 Environment Property
 SpecialFolders Property


Length Property
Applies To 		Windows Scripting Host Reference

WshEnvironment Object
WshArguments Object
WshCollection Object
WshSpecialFolders Object


Length Property
See Also 		Windows Scripting Host Reference

Arguments Property
Count Property


Name Property
Applies To 		Windows Scripting Host Reference

Wscript Object


Path Property
Applies To 		Windows Scripting Host Reference

Wscript Object


Path Property
See Also 		Windows Scripting Host Reference

FullName Property


ScriptFullName Property
Applies To 		Windows Scripting Host Reference

Wscript Object


ScriptFullName Property
See Also 		Windows Scripting Host Reference

ScriptName Property


ScriptName Property
Applies To 		Windows Scripting Host Reference

Wscript Object


ScriptName Property
See Also 		Windows Scripting Host Reference

ScriptFullName Property


SpecialFolders Property
Applies To 		Windows Scripting Host Reference

WshShell Object
WshSpecialFolders Object


SpecialFolders Property
See Also 		Windows Scripting Host Reference

WshSpecialFolders Object


TargetPath Property
Applies To 		Windows Scripting Host Reference

WshShortcut Object
WshUrlShortcut Object


UserDomain Property
Applies To 		Windows Scripting Host Reference

WshNetwork Object


UserName Property
Applies To 		Windows Scripting Host Reference

WshNetwork Object


Version Property
Applies To 		Windows Scripting Host Reference

Wscript Object


WindowStyle Property
Applies To 		Windows Scripting Host Reference

WshShortcut Object


WorkingDirectory Property
Applies To 		Windows Scripting Host Reference

WshShortcut Object