Windows Script Host  

WSH Walkthrough

The following walkthrough describes how a typical Network Administrator or other IT professional might use WSH 5.6 to create procedures that accomplish useful tasks.

Note   The walkthrough is presented in VBScript. The process for creating these scripts is nearly the same for developers using VBScript or JScript.

During the course of this walkthrough, you will perform the following activities:

To complete the walkthrough, all remote machines must be properly configured to enable Remote WSH. For more information on enabling these security settings, see Setting up Remote WSH.

Note   The following code is from the sample included in this documentation. To view the entire sample, see WSH Network Administrator Sample Script.

Create Variables and Constants

To create the necessary variables and constants

  1. In your text-scripting editor, enter the variables.
    Dim FSO
    Dim Services
    Dim SecDescClass
    Dim SecDesc
    Dim Trustee
    Dim ACE
    Dim Share
    Dim InParam
    Dim Network
  2. In your text-scripting editor, enter the constants, changing the values to reflect the UNC names and paths applicable to your network environment.
    Const FolderName = "C:\Public"
    Const AdminServer = "\\AdminMachine"
    Const ShareName = "Pubs"
    Const PrinterShare = "\\CorpPrinters\PrinterShare"

Connecting to a printer and setting it as default

To connect the machine to a common printing device

To set the machines default printing device

Creating a common share, copying files to it, and sharing it

To create a common share on the machine

To copy files to the newly created folder

To establish the newly created folder as a share with WMI

Running the Completed Script

The sample included in this documentation contains a complete, executable script with all of the functionality above. See WSH Network Administrator Sample Script.

Before running the script, ensure that all remote machines have been properly configured to run remote scripts. This is accomplished with Poledit.exe on the server. For more information, see Setting up Remote WSH.

When running remote WSH, the script is copied to the remote machines. Once the remote machine's security settings have been verified and the script is successfully copied, a return indicates success or failure. If successful, the script is then executed on the remote machines. For more information on running a remote WSH script, see Running Scripts Remotely.

See Also

Setting up Remote WSH | Accessing Networks | Running Scripts Remotely