开发者

Why is WSCript object not known to my script that's controlled by a custom IScriptControl?

开发者 https://www.devze.com 2023-01-25 06:17 出处:网络
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 \"vb

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消