我正在创建一个 VBS 脚本(一个恶作剧脚本),但当我单击“是”时,该脚本会执行下面所写的操作
if vbNo then
X=MsgBox("Please Restart. Your system will break down.",4+4096, ErR0r)
if vbNo then
X=MsgBox("e")
dim count
set object = wscript.CreateObject("wscript.shell")
do
object.run "error.vbs"
count = count + 1
loop until count = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
end if
if vbYes then
Dim IntCounter
Dim objWshShl : Set objWshShl = WScript.CreateObject("wscript.shell")
Dim objVoice : Set objVoice = WScript.CreateObject("sapi.spvoice")
ShutdownWarning()
TimedMessageBox()
ShutdownComputer()
Function ShutdownWarning
X=MsgBox("Thou hath been tricked", 0+4096)
WScript.Sleep 5000
End Function
Function TimedMessageBox
For IntCounter = 5 To 1 Step -1
objWshShl.Popup "Your time will be wasted in " _
& IntCounter & " seconds",1,"Computer Shutdown", 0+4096
Next
End Function
Function ShutdownComputer
objWshShl.Run "Shutdown /s /f /t 0",0
End Function
end if
我该如何解决这个问题?
vbNo
是等于
7
的常数值。
if vbNo
永远为真,因为
7
不是假值。需要使用变量来获取用户输入的返回值,如:
userInput = msgBox("click yes or no", vbYesNo)
if userInput = vbNo Then
' do something
end if