Copy Code code as follows:
Set wsh = CreateObject ("Wscript.Shell")
Wscript.Sleep 15 * 60 * 1000
Wsh.run "SHUTDOWN/S/T 0"
Double-click Run, unexpectedly pop-up error dialog box
Copy Code code as follows:
Line:1
Char:1
Error:wrong number of arguments or invalid property assignment: ' WSH '
Code:800a01c2
Source:microsoft VBScript Runtime Error
Accustomed to write a script with Vbsedit, do not vbsedit I wrote the vbs script? One word to check the word, did not find any grammatical errors, but double click is the error, it is a ghost!
Legend declares that the variable is a good programming habit, and then changed to
Copy Code code as follows:
Dim wsh
Set wsh = CreateObject ("Wscript.Shell")
Wscript.Sleep 15 * 60 * 1000
Wsh.run "SHUTDOWN/S/T 0"
This is not an error! How can it be! VBS is not a variable can not be declared! Usually write the procedure not all good!
Thought for a moment, found that usually use Vbsedit when the variable name is the editor with the snippets in the WshShell, is not the problem of variable names?
Copy Code code as follows:
' Dim WshShell
Set WshShell = CreateObject ("WScript. Shell ")
Wscript.Sleep 15 * 60 * 1000
Wshshell.run "SHUTDOWN/S/T 0"
This also does not have any question, appears is WSH this variable name to provoke the misfortune. Why not use this variable name? The only explanation is that it is a built-in variable of VBS, and WScript is also a built-in variable of VBS, is WSH a wscript alias?
Wsh.echo "Hello World"
MsgBox wsh.scriptfullname test results and WScript like, how can there be such a sick thing! I haven't seen it in any of the books, and there are no instructions in the reference manual.
To sum up:
1, WSH is the alias of WScript
2, dim can eliminate the VBS built-in variables
3, do not think that their VBS level is very high
Original: http://demon.tw/programming/vbs-wsh-wscript.html