Running Scripts from the Command Line
cscript service_info.vbs > c:\scripts\services.txt
cscript service_info.vbs >> c:\scripts\services.txt
cscript //nologo service_info.vbs > c:\scripts\services.txt
Parameter | Description |
---|---|
//B | Batch mode; suppresses display of user prompts and script errors. For example, if your script includes messages displayed using Wscript.Echo, these messages will not appear when the script runs in Batch mode. Batch mode also suppresses the use of VBScript functions such as Msgbox. The default is Interactive mode. |
//D | Turns on the Microsoft Script Debugger if this program is installed. The Script Debugger ships as part of Windows 2000, although it is not installed by default. The Script Debugger does not ship with Windows XP . If the Script Debugger is not installed, no error will occur. Instead, the script will simply run. |
//E:engine | Executes the script with the specified script engine. Among other things, this allows you to run scripts that use a custom file name extension. Without the //E argument, you can run only scripts that use registered file name extensions. For example, if you try to run this command: cscript test.admin You will receive this error message: Input Error: There is no script engine for file extension ".admin". To run a script that uses a custom file extension, include the //E argument: cscript //E:vbscript test.admin One advantage of using nonstandard file name extensions is that it guards against accidentally double-clicking a script and thus running something you really did not want to run. This does not create a permanent association between the .admin file name extension and VBScript. Each time you run a script that uses a .admin file name extension, you will need to use the //E argument. |
//H:CScript or //H:WScript | Registers Cscript.exe or Wscript.exe as the default application for running scripts. When WSH is initially installed, WScript is set as the default script host. |
//I | Interactive mode; allows display of user prompts and script errors. This is the default mode and is the opposite of Batch mode. |
//logo | Displays a logo when the script runs under CScript (this is the default setting for WSH). The logo, which appears prior to any of the output from the script, looks like this:Microsoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2000. All rights reserved. |
//nologo | Prevents display of the logo at run time (by default, the logo is displayed). The //nologo option is often used for scripts whose output is redirected to a text file. Suppressing the logo ensures that this information does not appear within the text file. This makes it easier to write scripts that parse the information found in the text file or that import the contents of the file to a database, because these scripts do not have to account for the logo. |
//S | Saves the Timeout and Logo options for this user. For example, this command ensures that the logo will be suppressed anytime a script runs under CScript: cscript //nologo //S You can also modify these settings by right-clicking a script file and then clicking Properties. |
//T:nn | Determines the maximum number of seconds the script can run. (The default is no limit.) The //T parameter prevents excessive execution of scripts by setting a timer. When execution time exceeds the specified value, the script host interrupts the script engine and terminates the process. |
//X | Starts the program in the Microsoft Script Debugger. If the Script Debugger is not installed, the script simply runs. |
//? | Displays a brief description of command parameters (the usage information). The usage information is similar to the information presented in this table, although with less explanation. For example, here is the usage information for the //E argument://E:engine Use engine for executing script |