我正在尝试使用 Windows 脚本主机命令行参数来运行 .js 文件。但是,每次运行时都会收到此错误,无论提供绝对路径或“wscript.exe”还是仅提供名称“wscript”,它都无法找到脚本引擎。我必须使用“//E”选项来指定要使用的脚本引擎,以测试某些内容。
我尝试了“scriptfile.js //E:C:\Windows\System32\wscript”、“scriptfile.js //E:C: \Windows\System32\wscript.exe" 和 "scriptfile.js //E:wscript" 但没有任何帮助。它给我错误“找不到脚本 scriptfile.js 的脚本引擎 C:\Windows\System32\wscript.exe”
Msdn 链接不提供示例命令用法,因此几乎没有对我有用,除了他们告诉我检查拼写和脚本引擎 - http://msdn.microsoft.com/en-us/library/s39f60wz(v=vs.85).aspx 和 http://msdn.microsoft.com/en-us/library/6kbz7235(v=vs.85 ).aspx
因此,如果有人成功使用 //E 选项指定需要专门使用“wscript”脚本引擎,请告诉我。
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.
发布评论
评论(2)
我认为 //E: 的选项是 //E:jscript 或 //E:vbscript
尝试:
这是我的尝试:
您可以输入 wscript /?在命令行上查看选项。
。
I think the options for the //E: are either //E:jscript or //E:vbscript
Try:
here's my attempt:
you can type wscript /? on the command line to see the options.
.
//E
参数用于指定脚本语言,而不是脚本主机可执行文件的路径。但如果您使用标准文件扩展名 — JScript 为 .js,VBScript 为 .vbs — Windows Script Host 将自动检测脚本语言,并且无需使用 //E 参数。这篇 TechNet 文章给出了 //E 参数的详细解释:
从命令行运行脚本。
话虽如此,要运行 .js 文件,您只需使用以下命令:
这将使用脚本主机的 GUI 版本运行脚本(以便
WScript.Echo
输出显示在消息中盒)。要使用脚本主机的控制台版本运行脚本(以便将
WScript.Echo
输出发送到控制台),请使用以下命令:使用脚本的默认版本运行脚本主机,只需在命令提示符处键入脚本名称:
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:
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:To run a script using the default version of the script host, simply type the script name at the command prompt: