Running Scripts With CScript

Embed Size (px)

Citation preview

  • 8/18/2019 Running Scripts With CScript

    1/2

    3/20/2016 Running Scripts with CScript.exe

    http://education.dewsoftoverseas.com/QE/QUickReference/WSH/htm/wsruncscript.htm 1/2

     Click here  to show toolbars of the Web Online Help System: show toolbars 

    Microsoft® Windows® Script Host

    Running Scripts withCScript.exe

     WSH Tutorial

    Previous

    Next

     

    CScript.exe is the version of Windows Script Host that enables you to run scripts from thecommand prompt. CScript.exe provides command-line switches for setting script properties. To use

    CScript.exe, type a command line at the command prompt using the following syntax:

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

    where the terms are defined as follows:

    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, complete with extension and any necessary

    path information, such as: d:\admin\vbscripts\chart.vbs.

    Script options and parameters  are passed to the script. Script parameters arepreceded 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.exe supports the host options shown in the following table.

    Parameter Description

     //I Interactive mode: allows display of user prompts and scri pt errors

    (this is the default, and the opposite of //B).

     //B Batch mode: suppresses command-line display of user prompts and

    script errors.

     //T:nn Enables time-out: the maxi mum number of seconds the scri pt can run.

    The default is no limit. (See the text following this table for more

    information on this parameter.)

     //logo Default. Displays a banner (opposite of //nologo).

     //nologo Prevents display of an execution banner at run time.

     //H:CScr ipt

    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.

     //S Saves the current command-line options for this user.

     //? Shows command usage (same as with param eters).

     //E:engine   Executes the script with the specified scripting engine.

     //D Turns on the debugger.

     //X Launches the program in the debugger.

     //Job:

    Runs the specified JobID from the .wsf file.

    The //T parameter prevents excessive execution of scripts by setting a timer. When execution time exceeds the specified value,CScript interrupts the scripting engine using the IActiveScript::InterruptThread  method and terminates the process.

    A CScript Example

    Several sample scripts are installed when you install the final release of the Windows Script Host.

    These are also available for download at: http://msdn.microsoft.com/scripting

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

    http://education.dewsoftoverseas.com/QE/QUickReference/WSH/htm/wsdraganddrop.htmhttp://education.dewsoftoverseas.com/QE/QUickReference/WSH/index.html?page=htm/wsruncscript.htmhttp://education.dewsoftoverseas.com/QE/QUickReference/WSH/index.html?page=htm/wsruncscript.htmhttp://msdn.microsoft.com/scriptinghttp://education.dewsoftoverseas.com/QE/QUickReference/WSH/htm/wsdraganddrop.htmhttp://education.dewsoftoverseas.com/QE/QUickReference/WSH/htm/wsrunwscript.htmhttp://education.dewsoftoverseas.com/QE/QUickReference/WSH/htm/wstutorialtoc.htmhttp://education.dewsoftoverseas.com/QE/QUickReference/WSH/index.html?page=htm/wsruncscript.htmhttp://education.dewsoftoverseas.com/QE/QUickReference/WSH/index.html?page=htm/wsruncscript.htm

  • 8/18/2019 Running Scripts With CScript

    2/2

    3/20/2016 Running Scripts with CScript.exe

    http://education.dewsoftoverseas.com/QE/QUickReference/WSH/htm/wsruncscript.htm 2/2

    c:\sample scripts\chart.vbs

    You can run the script with and without a logo, as follows:

    1. Choose the MS-DOS® operating system command prompt from Programs  on the Start

    menu.

    2. Enter the following commands at the command prompt (modify accordingly if your sample

    scripts are located in a different folder):

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

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

    © Dewsoft