Showing posts with label How to execute a VBscript. Show all posts
Showing posts with label How to execute a VBscript. Show all posts

Friday, September 28, 2007

WScript.exe and CScript.exe Options

For the most part, options listed in the following table are applicable to both WScript.exe and CScript.exe. Exceptions are noted.

/B Batch mode; suppresses command-line display of user prompts and script errors. Default is Interactive mode.
/D Turns on the debugger.
/E:engine Executes the script with the specified script engine.
/H:CScript or /H:WScript Registers CScript.exe or WScript.exe as the default application for running scripts. If neither is specified, WScript.exe is assumed as the default.
/I Default. Interactive mode; allows display of user prompts and script errors Opposite of Batch mode.
/Job: Runs the specified JobID from the .wsf file.
/logo Default. Displays a banner. Opposite of nologo.
/nologo Prevents display of an execution banner at run time. Default is logo.
/S Saves the current command-line options for this user.
/T:nn Enables time-out: 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, CScript interrupts the script engine using the IActiveScript::InterruptThread method and terminates the process.
/U Used with Windows NT and Windows 2000 to force the command line output to be in Unicode. There is no way for CScript to determine whether to output in Unicode or ANSI; it defaults to ANSI.
/X Launches the program in the debugger.
/? Displays a brief description of and usage information for command parameters (the usage information).

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.

Procedures

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

Thursday, September 27, 2007

How to Execute a VBScript

STEP 1 Copy the script into a notepad
STEP 2 Click save target as - In the file name type "name.vbs" [along with double quotes]
STEP 3 Choose drive
STEP 4 Goto the place where u saved and just double click name.vbs