將下面代碼存為vbs文件,如:shutdown.vbs,然后雙擊或在文件上點(diǎn)右
鍵選擇以命令提示打開(kāi),如果到了你設置重啟的時(shí)候,系統會(huì )出現關(guān)機的對話(huà)
框。
直接下面代碼程序會(huì )出現關(guān)機的對話(huà)框,最后的回車(chē)注釋掉了,正常使用
時(shí),請去掉注釋符。
以下代碼在window 2000 下通過(guò)。
復制代碼 代碼如下:
'定時(shí)關(guān)機或重啟的腳本,在windows 2000下通過(guò)
' code by haiwa 2005-11-7
dim ActionID
ActionID = 1 '0注銷(xiāo),1關(guān)機,2重啟,
ActionTime = "2005-11-7 13:42:30" '關(guān)機或重啟時(shí)間
function ShutDown()
dim objShell
Set objShell = WScript.CreateObject("Wscript.Shell")
dim Application
set Application = CreateObject("Shell.Application.1")
Application.ShutdownWindows()
dim upi
for upi = 0 to 4
WScript.Sleep(50)
objShell.sendKeys("{UP}")
next
For upi = 1 to ActionID
WScript.Sleep(50)
objShell.sendKeys("{DOWN}")
next
'使用時(shí),請把下行的注釋符去掉
'objShell.sendKeys("{ENTER}")
end function
While true
if DateDiff("s", Now, ActionTime) < 0 then
ShutDown()
end if
WScript.Sleep(5*1000)
wend