VBScript and CreateObject issue

后端 未结 1 995
臣服心动
臣服心动 2020-12-04 03:50

I\'m not really experimented if it is about VBScript but I had the occasion to read many things through forums and actually yesterday I helped someone to checkout why his sc

相关标签:
1条回答
  • 2020-12-04 04:43

    The "WScript" in "WScript.CreateObject" or "WScript.Echo" is (the name of an object) provided by the c|wscript.exe scripting host. If you run VBScript under/in other hosts (e.g. ie or mshta), there is no such object.

    The language itself has a (different!, see the docs for details) "CreateObject" function, that can be used under/in all VBScripts hosts. So use plain "CreateObject" to be on the safe side.

    The WScript in "WScript.Network" is part of the ProgId of a COM object that may be installed on your computer (or not). Those COM objects with a 'first name' of "WScript" are completely different from the WScript object provided by c|wscript.exe.

    So my first assumption: The "someone" executed the code under/in ie or mshta and solved the problem by removing the "WScript." from "WScript.CreateObject", that is by falling back to VBScript's own CreateObject.

    0 讨论(0)
提交回复
热议问题