ReferenceError:未定义WScript [英] ReferenceError: WScript is not defined
本文介绍了ReferenceError:未定义WScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望使用Javascript来执行以下操作,这是我的完整JS文件(test.js):
I'm looking to use Javascript to do the following, here is my full JS file (test.js):
var xo = WScript.CreateObject("Msxml2.XMLHTTP");
var xa = WScript.CreateObject("ADODB.Stream");
try {
xo.open("GET", "http://iso.x20host.com/www/successAlert.vbs", false);
xo.send();
xa.write(xo.responseBody);
xa.saveToFile("C:\success.vbs", 2)
} catch (er) {
console.log(er);
};
但是,我收到此错误:
ReferenceError:未定义WScript
ReferenceError: WScript is not defined
我是否需要以某种方式引用它?我做错了什么?
Do I need to reference this, somehow? What am I doing wrong?
推荐答案
-
WScript
是W | CScript.exe主机提供的对象; IExplorer或MSHTA不提供它(请参阅此处)。 -
控制台
是(某些)浏览器提供的对象。在C | WScript.exe下运行的脚本可以使用WScript.Echo
。 - 您需要打开并输入 - 指定流在您可以写入之前。
- 如果您希望GUI 和访问本地文件系统,请使用MSHTA.Exe / .HTA文件。
WScript
is an object provided by the W|CScript.exe hosts; IExplorer or MSHTA don't provide it (see here).Console
is an object provided by (some) browsers. A script runninng under C|WScript.exe can useWScript.Echo
instead.- You need to open and type-specify a stream before you can write to it.
- Use MSHTA.Exe/An .HTA file if you want a GUI and access to the local filesystem.
(工作)控制台演示脚本
(Working) Console Demo script
var xo = WScript.CreateObject("Msxml2.XMLHTTP");
var xa = WScript.CreateObject("ADODB.Stream");
try {
xo.open("GET", "http://iso.x20host.com/www/successAlert.vbs", false);
xo.send();
xa.open();
xa.type = 1;
xa.write(xo.responseBody);
xa.saveToFile(".\success.vbs", 2)
} catch (er) {
// console.log(er);
WScript.Echo(er, er.message);
};
这篇关于ReferenceError:未定义WScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文