Several Methods for running the Windows Script Host

Source: Internet
Author: User
1. Run the script at the command prompt.
Use the Windows Script Host to run the script at a command prompt. CScript.exe provides command line switches for setting script attributes.

Run the script using CScript.exe

Enter the command at the command prompt using the following syntax:
Cscript [host options...] [script name] [script options and parameters]
You can use "host options" to enable or disable various Windows Script Host functions. The host option has two front slashes (//). "Script Name" is the name of the script file with the extension and required path information, such as d: \ admin \ vbscripts \ chart. vbs. "Script options and Parameters" will be passed to the script. There is a slash (/) before the script parameter (/).

Each parameter is optional, but the script option cannot be specified without the Script Name. If no parameter is specified, CScript displays the CScript syntax and valid host parameters.

CScript example
Several sample scripts installed with the Windows Script Host can also be downloaded from (http://www.microsoft.com/china/scripting.

Assume that the script in Chart. vbs is copied to the following folder on the computer:

C: \ sample scripts \ chart. vbs
You can run the script with or without a logo as follows.

Run a script with or without a logo

Start the MS-DOS command prompt.
Enter the following command at the command prompt (if the sample script is in another folder, modify it accordingly ):
Cscript // logo c: \ "sample scripts" \ chart. vbs
Cscript // nologo c: \ "sample scripts" \ chart. VBScript
2. run scripts from Windows
Windows Script Host

Run scripts from Windows
You can run scripts from Windows using the Windows Script Host. WScript.exe provides a Windows-based dialog box for setting script properties. With WScript.exe, you can run scripts from Windows in the following ways. Whether WScript or Cscript is used, the running mode of the script remains unchanged. The only difference is that the output is different-WScript generates window output, and CScript sends the output to the Command window that starts it.

During the initial installation, the default host is WScript. To change it to Cscript, type the following in the command line:

Cscript // h: cscript
Alternatively, to convert Cscript into Wscript, enter the following content:

Wscript // h: cscript
Run the script using the default engine:

Double-click the script in "Windows Resource Manager" or on the desktop.
Click Start, select Run, and enter the Script Name.
Note that you can only enter the script name in the command line, but this is only applicable to Windows NT and Windows 2000.
Run the script using a special engine:

To run as WScript, right-click the script in "Windows Resource Manager" and select "open". To run as Cscript, select open in MS-DOS window for Windows 9x or open in command window for Windows NT and Windows 2000 ).
-Or-

Click Start, select Run, enter cscript or wscript, and enter the Script Name.
-Or-

Enter "cscript" or "wscript" in the command line, and then enter the Script Name.
Run the script using WScript.exe

Double-click a file or icon. They may be my computer, Windows Resource Manager, find window, Start Menu, or files or icons listed on the desktop.
-Or-
Click Start, and then click Run ".
In the open area, enter the complete script path and click OK ". You can also type Wscript and enter the complete name and path of the script to be run.
If the extension of the double-click script file is not associated with WScript.exe, the "open mode" dialog box appears, asking which program is used to open the file. Select WScript and select "always use this program to open these files" to register WScript as the default application for all files with this extension.

The WScript.exe and CScript.exe Properties dialog boxes provide the following options:

Attribute: stops the script after the specified number of seconds. Description: specifies the maximum number of seconds that a script can run. The default setting is unlimited.
CScript.exe is equivalent to: // T: nn

The logo is displayed when the script is executed in the command console. Note: The title is displayed before the script is run. This is the default setting. The opposite is set to // nologo.
CScript.exe is equivalent to: // logo or // nologo

You can use the "properties" dialog box of WScript.exe to set global script options for all scripts running on the local computer. You can also use the. wsf file to set options for each script.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.