The difference between CreateObject and WScript.CreateObject one:
CreateObject is a built-in function of VBS, part of the language, and WScript.CreateObject is a method of WScript objects provided by Windows Script hosts (Wscript.exe and Cscript.exe). Similar to the relationship between internal commands and external commands in a batch. In the VBS, CreateObject is always available, and wscript.createobject can be used only if the host is Wscript.exe and Cscript.exe, in WMI, QTP, SECURECRT, Other hosting environments, such as EmEditor, are not available.
the difference between CreateObject and WScript.CreateObject two:
If you use only the first argument, then CreateObject and WScript.CreateObject are almost identical, but if you use the second argument, the two are completely different. The second parameter of CreateObject is used to create the object on the remote server through DCOM, while the second parameter of WScript.CreateObject is used to create the local object and respond to the event.
A simple example of a response to an event:
Copy Code code as follows:
Dim IE
Set IE = WScript.CreateObject ("Internetexplorer.application", "Ie_")
Ie. Visible = True
Ie. Navigate "Http://www.jb51.net"
Todo
Wscript.Sleep 1000
Loop
Sub Ie_onquit ()
MsgBox "is shutting down Demon ' s Blog"
Wscript.Quit
End Sub
the difference between CreateObject and WScript.CreateObject three:
Because CreateObject is a built-in function of VBS and does not need to be invoked through COM, CreateObject is a little bit faster than wscript.createobject (though almost negligible):
Copy Code code as follows:
t = Timer
For i = 1 to 100000
Set WshShell = WScript.CreateObject ("Wscript.Shell")
Next
WScript.Echo Timer-t
' By Demon
t = Timer
For i = 1 to 100000
Set WshShell = CreateObject ("Wscript.Shell")
Next
WScript.Echo Timer-t
Demon's advice: try to use the CreateObject function unless you need to respond to the event. There are at least three benefits: portability, faster, and shorter code.
Author: Demon
Link: http://demon.tw/programming/vbs-createobject-wscript-createobject.html