I am trying to use the windows scripting host command line argumet to run a .js file. However, everytime I run I get this error that it cannot find the script engine irrespective of providing absolute path or "wscript.exe" or just the name "wscript". I must use the "//E" option to to specify the script engine to use, to test something.
I tried "scriptfile.js //E:C:\Windows\System32\wscript", "scriptfile.js //E:C:\Windows\System32\wscript.exe" and "scriptfile.js //E:wscript" but nothing helps. It gives开发者_如何转开发 me the error "Can't find script engine C:\Windows\System32\wscript.exe" for script scriptfile.js"
Msdn links do not provide a sample command usage so it almost of no use to me, except that they inform me to check the spelling and the script engine - http://msdn.microsoft.com/en-us/library/s39f60wz(v=vs.85).aspx and http://msdn.microsoft.com/en-us/library/6kbz7235(v=vs.85).aspx
So if someone has successfully used the //E option to specify that "wscript" script engine needs to be used specifically, please do let me know.
I think the options for the //E: are either //E:jscript or //E:vbscript
Try:
wscript //E:jscript scriptfile.js
here's my attempt:
you can type wscript /? on the command line to see the options.
.The //E
argument is used to specify the script language rather than the path to the script host executable. But if you use standard file extensions — .js for JScript and .vbs for VBScript — Windows Script Host will automatically detect the script language, and there's no need to use the //E argument.
Somewhat detailed explanation of the //E parameter is given in this TechNet article:
Running Scripts from the Command Line.
Having said that, to run a .js file you can simply use the following command:
wscript C:\myscript.js
This will run the script using the GUI version of the script host (so that the WScript.Echo
output is displayed in message boxes).
To run a script using the console version of the script host (so that the WScript.Echo
output is send to the console), use the following command:
cscript C:\myscript.js
To run a script using the default version of the script host, simply type the script name at the command prompt:
C:\myscript.js
精彩评论