Home > Articles > Home & Office Computing > Microsoft Windows Desktop

  • Print
  • + Share This
This chapter is from the book

Using WScript for Windows-Based Scripts

The .vbs and .js file types have an open method that's associated with WScript (WScript.exe), which is the Windows-based front-end for the Windows Script Host. In other words, launching a script file named, for example, MyScript.vbs is equivalent to entering the following command in the Run dialog box:

wscript myscript.vbs

The WScript host also defines several parameters that you can use to control the way the script executes. Here's the full syntax:

WSCRIPT [filename] [arguments] [//B] [//D] [//E:engine] [//H:host] [//I] [//Job:xxxx] [//S] [//T:ss] [//X]


Specifies the filename, including the path of the script file, if necessary.


Specifies optional arguments required by the script. An argument is a data value that the script uses as part of its procedures or calculations.


Runs the script in batch mode, which means script errors and Echo method output lines are suppressed.


Enables Active Debugging. If an error occurs, the script is loaded into the Microsoft Script Debugger (if it's installed), and the offending statement is highlighted.


Executes the script using the specified scripting engine, which is the scripting language to use when running the script.


Specifies the default scripting host. For host, use either CScript or WScript.


Runs the script in interactive mode, which displays script errors and Echo method output lines.


In a script file that contains multiple jobs, executes only the job with id attribute equal to id.


Saves the specified WScript arguments as the default for the current user; uses the following Registry key to save the settings:

HKCU\Software\Microsoft\Windows Script Host\Settings


Specifies the maximum time in seconds (ss) that the script can run before it shuts down automatically.


Executes the entire script in the Microsoft Script Debugger (if it's installed).

For example, the following command runs MyScript.vbs in batch mode with a 60-second maximum execution time:

wscript myscript.vbs //B //TT:60
  • + Share This
  • 🔖 Save To Your Account