为什么由自定义 IScriptControl 控制的脚本不知道 WSCript 对象?
我正在使用其他人的库,它提供了自己的脚本主机实例,看起来。
该库为我提供了定义脚本语言类型的函数,例如“jscript”和“vbscript”,我可以为其提供脚本代码并执行该代码,并传入和传回参数。所以,基本上,它是有效的。
但是,当我尝试访问“WScript”对象时,出现异常,提示该关键字未定义。
开发人员对此也不太了解(他只是为我制作了这个库,因为我现在不想处理 Windows SDK),他告诉我他正在为此使用“IScriptControl”。
哦,该库还提供了允许“仅安全子集”和“允许 UI”的标志,我分别将其设置为 false 和 true。
这对任何人来说都敲响了警钟吗? IScriptControl 的用户是否必须采取额外的步骤才能使 WScript 对象可用?或者,他能否以自动提供的方式使用 IScriptControl,就像从 wscript.exe 运行相同的脚本一样?
基本上,我需要的只是 WScript.CreateObject 函数,以便通过 COM 访问另一个应用程序的 API。
I am using someone else's library that provides its own scripting host instance, it appears.
This lib provides me with functions to define the type of scripting language such as "jscript" and "vbscript", and I can supply it with script code and have that executed, with passing arguments in and back. So, basically, it works.
However, when I try to access the "WScript" object, I get an exception saying that this keyword is undefined.
The developer, not knowing much about this either (he only made this lib for me because I do not want to deal with Windows SDKs right now), told me that he is using "IScriptControl" for this.
Oh, and the lib also provides flags to allow "only safe subset" and "allow UI", which I set to false and true, respectively.
Does that ring a bell with anyone? Do a user of IScriptControl have to take extra steps in order to make a WScript object available? Or, can he use IScriptControl in a way that this is supplied automatically, just as when running the same script from wscript.exe?
Basically, all I need is the WScript.CreateObject function in order to access another app's API via COM.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道为什么 WScript 不为人所知,但我怀疑这是因为脚本宿主不提供它。也许只有 wscript.exe 可以做到这一点。
如果您使用的是 Javascript,则可以使用
new ActiveXObject()
创建对象。如果您使用 VBScript,则只需使用CreateObject
即可。请参阅本文了解一些背景信息。
I don't know why WScript is not known, but I suspect it is because the script host doesn't provide it. Maybe only wscript.exe does this.
If you are using Javascript, to create an object you can use
new ActiveXObject()
. If you are using VBScript, you can just useCreateObject
.See this article for some background.