为什么由自定义 IScriptControl 控制的脚本不知道 WSCript 对象?

发布于 2024-10-02 14:34:55 字数 514 浏览 1 评论 0原文

我正在使用其他人的库,它提供了自己的脚本主机实例,看起来。

该库为我提供了定义脚本语言类型的函数,例如“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

复古式 2024-10-09 14:34:55

我不知道为什么 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 use CreateObject.

See this article for some background.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文