Anda di halaman 1dari 2

3/20/2016

RunningScriptswithCScript.exe

ClickheretoshowtoolbarsoftheWebOnlineHelpSystem:showtoolbars

MicrosoftWindowsScriptHost

RunningScriptswith
CScript.exe

WSHTutorial
Previous
Next

CScript.exeistheversionofWindowsScriptHostthatenablesyoutorunscriptsfromthe
commandprompt.CScript.exeprovidescommandlineswitchesforsettingscriptproperties.Touse
CScript.exe,typeacommandlineatthecommandpromptusingthefollowingsyntax:

cscript[hostoptions...][scriptname][scriptoptionsandparameters]
wherethetermsaredefinedasfollows:

HostoptionsenableordisablevariousWindowsScriptHostfeatures.Hostoptionsare
precededbytwoslashes(//).

Scriptnameisthenameofthescriptfile,completewithextensionandanynecessary
pathinformation,suchas:d:\admin\vbscripts\chart.vbs.

Scriptoptionsandparametersarepassedtothescript.Scriptparametersare
precededbyasingleslash(/).
Eachparameterisoptionalhowever,youcannotspecifyscriptoptionswithoutspecifyingascript
name.Ifyoudonotspecifyparameters,CScriptdisplaystheCScriptsyntaxandthevalidhost
parameters.CScript.exesupportsthehostoptionsshowninthefollowingtable.
Parameter

Description

//I

Interactivemode:allowsdisplayofuserpromptsandscripterrors
(thisisthedefault,andtheoppositeof//B).

//B

Batchmode:suppressescommandlinedisplayofuserpromptsand
scripterrors.

//T:nn

Enablestimeout:themaximumnumberofsecondsthescriptcanrun.
Thedefaultisnolimit.(Seethetextfollowingthistableformore
informationonthisparameter.)

//logo

Default.Displaysabanner(oppositeof//nologo).

//nologo

Preventsdisplayofanexecutionbanneratruntime.

//H:CScript RegistersCScript.exeorWScript.exeasthedefaultapplicationfor
or
runningscripts.Ifneitherisspecified,WScript.exeisassumedasthe
//H:WScript default.
//S

Savesthecurrentcommandlineoptionsforthisuser.

//?

Showscommandusage(sameaswithparameters).

//E:engine

Executesthescriptwiththespecifiedscriptingengine.

//D

Turnsonthedebugger.

//X

Launchestheprograminthedebugger.

//Job:
<JobID>

RunsthespecifiedJobIDfromthe.wsffile.

The//Tparameterpreventsexcessiveexecutionofscriptsbysettingatimer.Whenexecutiontimeexceedsthespecifiedvalue,
CScriptinterruptsthescriptingengineusingtheIActiveScript::InterruptThreadmethodandterminatestheprocess.

ACScriptExample

SeveralsamplescriptsareinstalledwhenyouinstallthefinalreleaseoftheWindowsScriptHost.
Thesearealsoavailablefordownloadat:http://msdn.microsoft.com/scripting
Suppose,forthepurposesofthisexample,thatyouhavecopiedtheChart.vbssamplescripttothefollowingfolderonyour
computer:

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

1/2

3/20/2016

RunningScriptswithCScript.exe
c:\samplescripts\chart.vbs
Youcanrunthescriptwithandwithoutalogo,asfollows:

1.ChoosetheMSDOSoperatingsystemcommandpromptfromProgramsontheStart
menu.
2.Enterthefollowingcommandsatthecommandprompt(modifyaccordinglyifyoursample
scriptsarelocatedinadifferentfolder):

cscript//logoc:\"samplescripts"\chart.vbs
cscript//nologoc:\"samplescripts"\chart.vbs
Dewsoft

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

2/2

Anda mungkin juga menyukai