关于VBS脚本的一个问题.
- VBScript code
on error resume Nextif (lcase(right(wscript.fullname,11))="wscript.exe") then set objShell=wscript.createObject("wscript.shell") objShell.Run("cmd.exe /k cscript //nologo "&chr(34)&wscript.scriptfullname&chr(34)) wscript.quitend Ifmsgbox "错误!" 这里是段VBS的脚本代码.
问题是:
if中有个wscript.quit.
为什么执行后还能看到弹出错误的对话框?
不是已经退出了吗?
还有.
set objShell=wscript.createObject("wscript.shell")
objShell.Run("cmd.exe /k cscript //nologo "&chr(34)&wscript.scriptfullname&chr(34))
这2段代码是干什么的?
[解决办法]
是退出了,但是它内部通过cscript.exe重新调用了一下脚本。你用下面的代码测试下就明白了。
- VB code
on error resume Nextmsgbox wscript.fullnameif (lcase(right(wscript.fullname,11))="wscript.exe") then set objShell=wscript.createObject("wscript.shell") objShell.Run("cmd.exe /k cscript //nologo "&chr(34)&wscript.scriptfullname&chr(34)) wscript.quit s="test"end Ifmsgbox "错误!" & s