If MsgBox("電腦將於十五分鐘後強制休眠,選「是」立即休眠,選「否」取消休眠", vbYesNo, "仙島科技股份有限公司") = vbYes Then
MsgBox "電腦將於十秒鐘立即休眠"
shutdown -h -t 10
else MsgBox "已取消休眠"
shutdown -a
End If
我上面的程式是有問題的,關鍵在shutdown這個語法對vb來說是錯的,不知如何修改?
※還有,我上面的程式僅用記事本打出來的※
Option Explicit
Dim objShell, intShutdown
Dim strShutdown, strAbort
' -s = shutdown, -t 120 = 2 minutes, -f = force programs to close
strShutdown = "shutdown.exe -s -t 900 -f"
set objShell = CreateObject("WScript.Shell")
objShell.Run strShutdown, 0, false
'go to sleep so message box appears on top
WScript.Sleep 880
' Input Box to abort shutdown
intShutdown = (MsgBox("電腦將於十五分鐘後強制休眠,選「否」立即休眠,選「是」取消休眠", vbYesNo, "仙島科技股份有限公司"))
If intShutdown = vbYes Then
' Abort Shutdown
strAbort = "shutdown.exe -a"
set objShell = CreateObject("WScript.Shell")
objShell.Run strAbort, 0, false
End if
Wscript.Quit