简体   繁体   English

VBScript和CreateObject问题

[英]VBScript and CreateObject issue

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 script wasn't working and found him a solution. 我不是真的尝试过有关VBScript的问题,但是我有机会通过论坛阅读了很多东西,实际上昨天我帮助某人检查了为什么他的脚本不起作用并找到了解决方案。 So I modified this script locally and did it the way I would and it worked but on that other person side one of the object couldn't be initialized. 因此,我在本地修改了该脚本,并按照我的方式进行了修改,并且可以正常工作,但是在另一端,无法初始化该对象之一。

The incriminated line is like 斜线像

    Set WshNet = WScript.CreateObject("WScript.Network")

Another person told to remove the WScript thing and it seems it works on the question asker side. 另一个人告诉您删除WScript内容,看来它可以在问题提问者方面使用。

I first thought it might be linked with the use of Wscript.exe on my side and CScript.exe on that person side (my hypothesis) but I checked this out in the command-line and it worked anyway. 我最初以为它可能与我这一边的Wscript.exe和该人那一边的CScript.exe的使用有关(我的假设),但是我在命令行中检查了一下,无论如何它都能正常工作。 So, what I would like to know and understand is why is this happening ? 所以,我想知道和理解的是为什么会这样? Why does a script calling for CreateObject works with "WScript." 为什么调用CreateObject的脚本可以与“ WScript”一起使用。 but on another system you need to remove that "WScript." 但是在另一个系统上,您需要删除该“ WScript”。 to keep it working ? 保持工作? Thank you for your time and answers. 感谢您的时间和答复。 ;) Best regards. ;) 最好的祝福。

The "WScript" in "WScript.CreateObject" or "WScript.Echo" is (the name of an object) provided by the c|wscript.exe scripting host. “ WScript.CreateObject”或“ WScript.Echo”中的“ WScript”是c | wscript.exe脚本宿主提供的(对象的名称)。 If you run VBScript under/in other hosts (eg ie or mshta), there is no such object. 如果在其他主机(例如ie或mshta)下/中运行VBScript,则没有此类对象。

The language itself has a (different!, see the docs for details) "CreateObject" function, that can be used under/in all VBScripts hosts. 该语言本身具有一个“ CreateObject”功能(不同!请参见文档以获取详细信息),该功能可以在所有VBScripts主机下/中使用。 So use plain "CreateObject" to be on the safe side. 因此,使用简单的“ CreateObject”是安全的。

The WScript in "WScript.Network" is part of the ProgId of a COM object that may be installed on your computer (or not). “ WScript.Network”中的WScript是COM对象的ProgId的一部分,该COM对象可以安装在计算机上(也可以不安装在计算机上)。 Those COM objects with a 'first name' of "WScript" are completely different from the WScript object provided by c|wscript.exe. 那些带有“ WScript”“名字”的COM对象与c | wscript.exe提供的WScript对象完全不同。

So my first assumption: The "someone" executed the code under/in ie or mshta and solved the problem by removing the "WScript." 因此,我的第一个假设是:“某人”在ie或mshta下/中执行代码,并通过删除“ WScript”解决了问题。 from "WScript.CreateObject", that is by falling back to VBScript's own CreateObject. 从“ WScript.CreateObject”开始,即回退到VBScript自己的CreateObject。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在VBScript中反转CreateObject - Reverse CreateObject in VBScript 在VBScript中重写CreateObject函数 - Overriding CreateObject Function in VBScript VBScript CreateObject 谷歌浏览器 - VBScript CreateObject Google Chrome VBScript:通过createobject分配一个数组(2) - VBScript: Assigning an array(2) via createobject Server.CreateObject(“ Wscript.Shell”)问题-对象服务器必需的错误??? ASP / VBscript错误 - Server.CreateObject(“Wscript.Shell”) issue - Object Server required error??? ASP/VBscript error Server.CreateObject(“Scripting.FileSystemObject”)问题 - 需要对象:服务器(代码:0)ASP/VBscript - Server.CreateObject(“Scripting.FileSystemObject”) issue - Object required:Server (code:0) ASP/VBscript 什么是VBScript CreateObject()的等效JavaScript函数 - what is the equivalent JavaScript function for VBScript CreateObject() vbscript中CreateObject(“ Excel.Application”)上的“内存不足” - “Out of Memory” on CreateObject(“Excel.Application”) in vbscript 在vbscript中使用createobject使用宏打开Excel - Opening Excel with Macros using createobject in vbscript VBScript可以自动登录网站并通过CreateObject(InternetExploerer)执行操作吗? - Can VBScript automatically log into a website and perform actions via CreateObject(InternetExploerer)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM