Windows Script Host  

Running Scripts from Windows

Windows Script Host enables you to run scripts from Windows. WScript.exe provides a Windows-based dialog box for setting script properties. Using WScript.exe, you can run scripts under Windows in the following ways. Whether you use WScript or CScript, you still run the scripts in the same manner. The difference is only in the output — WScript generates windowed output, while CScript sends its output to the command window in which it was started.

On initial installation, the default host is WScript. To change it to CScript, type the following at the command line:

cscript //h:cscript

Or, to change it from Cscript to Wscript:

wscript //h:cscript

To run a script using the default engine:

  1. Double click the script in Windows Explorer or on the desktop.
  2. Click Start, select Run, and enter the script name.
    Note   On Windows NT and Windows 2000 only, simply enter the script name on a command line.

To run a script using a particular engine:

-or-

-or-

To run scripts using WScript.exe

-or-

  1. Click the Start button, and then click Run.
  2. In the Open field, type the full path of the script, and then click OK. You can also type 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, the Open With dialog box appears and asks which program to use to open the file. Choose WScript and check Always use this program to open this file to register WScript as the default application for all files with that extension.

The WScript.exe and CScript.exe properties dialog box provides the following options:

Property Description
Stop script after specified number of seconds. Specifies the maximum number of seconds that a script can run. The default is no limit.

CScript.exe equivalent: //T:nn

Display logo when script is executed in command console. Displays a banner before running the script. This is the default. The opposite is //nologo.

CScript.exe equivalent: //logo or //nologo

Using the WScript.exe Properties dialog box, you can set global scripting options for all scripts that WScript runs on the local machine. You can also set options for individual scripts using a .wsf file.

See Also

Running Scripts from the Command Prompt | What to Include to Run a Script | WScript.exe and CScript.exe Options