当按下“是”时,此代码应打开脚本以模拟计时器,或者在按下“否”时打开脚本以模拟警报。当按下“是”时,它按预期工作,但是当按下“否”时,它仍然打开计时器脚本而不是警报脚本。
Pick = MsgBox("Do you want a Timer?", 4+32, "Choose one")
If vbYes Then
CreateObject("WScript.Shell").Run("""C:\Users\Username\Documents\Applications\Reminder\Reminder Script.vbs""")
WScript.Quit
Else
CreateObject("WScript.Shell").Run("""C:\Users\Username\Documents\Applications\Alarm\Alarm Script.vbs""")
WScript.Quit
End If
答案 0 :(得分:0)
AFAIK你可以用两种方式做到这一点(见下文 - 请原谅语法)。在您的问题的评论中, GSerg 和 pinkfloydx33 回答了If ... Then ... Else方法......
set wshell = createobject("wscript.shell")
'**If...Then...Else**
pick = msgbox("Do you want a timer?", 4+32, "Choose one")
if pick = vbyes then
'wshell.run("""c:\users\username\documents\applications\reminder\reminder script.vbs""")
wscript.echo "Reminder"
else
'whsell.run("""c:\users\username\documents\applications\alarm\alarm script.vbs""")
wscript.echo "Alarm"
end if
'**Select...Case**
pick = msgbox("Do you want a timer?", 4+32, "Choose one")
select case pick
case vbyes
'wshell.run("""c:\users\username\documents\applications\reminder\reminder script.vbs""")
wscript.echo "Reminder"
wscript.quit
case vbno
'whsell.run("""c:\users\username\documents\applications\alarm\alarm script.vbs""")
wscript.echo "Alarm"
wscript.quit
end select
希望这有帮助。
此外,MSDN VBScript User guide可能有助于更好地解释变量等。