Friday, September 28, 2007

Running Scripts from the Command Prompt

Content from Microsoft site.

Windows Script Host enables you to run scripts from the command prompt. CScript.exe provides command-line switches for setting script properties.


To run scripts using CScript.exe
Type a command at the command prompt using the following syntax:

Copy Code

cscript [host options...] [script name] [script options and parameters]

Host Options enable or disable various Windows Script Host features. Host options are preceded by two slashes (//).Script name is the name of the script file with extension and necessary path information, for example, d:\admin\vbscripts\chart.vbs. Script options and parameters are passed to the script. Script parameters are preceded by a single slash (/).

Each parameter is optional; however, you cannot specify script options without specifying a script name. If you do not specify parameters, CScript displays the CScript syntax and the valid host parameters.

CScript Example

Suppose, for the purposes of this example, that you have copied the Chart.vbs sample script to the following folder on your computer:

Copy Code

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

To run a script with or without a logo
Start the MS-DOS command prompt.

Enter the following commands at the command prompt (modify accordingly if your sample scripts are located in a different folder):

Copy Code

cscript //logo c:\"sample scripts"\chart.vbs

cscript //nologo c:\"sample scripts"\chart.VBScript

No comments: