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.
To Change to CScript
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
Procedures
To run a script using the default engine:
Double click the script in Windows Explorer or on the desktop.
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:
- Right-click the script in Windows Explorer and select Open to run in WScript or Open in MS-DOS Window (Windows 9x) or Open in Command Window (Windows NT and Windows 2000) to run in CScript.
-or-
- Click Start, select Run, enter "cscript" or "wscript" followed by the script name.
-or-
- Enter "cscript" or "wscript" on the command line, followed by the script name.
To run scripts using WScript.exe
- Double-click 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.
-or-
Click the Start button, and then click Run.
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 // 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
Concepts
Running Scripts from the Command Prompt
What to Include to Run a Script
WScript.exe and CScript.exe Options