可以定時(shí)自動關(guān)機(jī)的vbs腳本
Dim mytime,myout1,myout2
mytime=null
mytime=InputBox("請輸入定時(shí)時(shí)間(格式20:10:05)"&vblf&"如果想倒計(jì)時(shí)關(guān)機(jī),請輸入倒計(jì)時(shí)時(shí)間"&vblf&"(單位/分鐘)"&vblf&"輸入‘xxx'可以馬上關(guān)機(jī)"&vblf&"退出點(diǎn)‘取消'","定時(shí)關(guān)機(jī)","1")
Set wshshell=wscript.createobject("wscript.shell")
If IsNumeric(mytime)=False Then
If IsDate(mytime)=True Then
wshshell.run "at "&mytime&" shutdown -s" '定時(shí)關(guān)機(jī)在任務(wù)列表中
myout1=MsgBox("定時(shí)成功!電腦將在"&mytime&"關(guān)機(jī)!放棄關(guān)機(jī)請點(diǎn)‘取消'!",vbokcancel,"定時(shí)關(guān)機(jī)")
If myout1=vbcancel Then
wshshell.run "at /delete /y"
MsgBox "關(guān)機(jī)已取消!",64,"定時(shí)關(guān)機(jī)"
End If
Else
If mytime="xxx" Then
wshshell.run "shutdown -s -t 0"
End If
MsgBox "輸入錯誤!請重新輸入!",64,"定時(shí)關(guān)機(jī)"
End If
Else
If mytime>600 Or mytime<=0 Then
MsgBox "輸入錯誤!倒計(jì)時(shí)不能多于10小時(shí)(600分鐘)!",64,"定時(shí)關(guān)機(jī)"
wscript.quit
End If
wshshell.run "shutdown -s -t "&mytime*60
myout2=MsgBox("設(shè)置成功!電腦將在"&mytime&"分鐘后關(guān)機(jī)!放棄關(guān)機(jī)請點(diǎn)‘取消'!",vbokcancel,"定時(shí)關(guān)機(jī)")
If myout2=vbcancel Then
wshshell.run "shutdown -a"
MsgBox "關(guān)機(jī)已取消!",64,"定時(shí)關(guān)機(jī)"
End If
End If
set diaolei=createobject("wscript.shell")
dim shijian,guanji,hua
shijian=time
hua=inputbox("請輸入你要用什么單位關(guān)機(jī) 1 代表分鐘 2 代表小時(shí) 3 代表天")
if hua=1 then
guanji=inputbox("請輸入你要幾分鐘后關(guān)機(jī)")
if datediff("m",shijian,time)>=guanji then
diaolei.run "rundll32.exe user.exe,exitwindows"
diaolei.run "shutdown -s -t 0"
elseif hua=2 then
guanji=inputbox("請輸入你要幾小時(shí)后關(guān)機(jī)")
if datediff("h",shijian,time)>=guanji then
diaolei.run "rundll32.exe user.exe,exitwindows"
diaolei.run "shutdown -s -t 0"
elseif hua=3 then
guanji=inputbox("請輸入你要幾天后關(guān)機(jī)")
if datediff("d",shijian,time)>=guanji then
diaolei.run "rundll32.exe user.exe,exitwindows"
diaolei.run "shutdown -s -t 0"
endif
上一篇:利用wscript執(zhí)行文件[包括可執(zhí)行exe文件]vbs腳本
欄 目:vb
本文標(biāo)題:可以定時(shí)自動關(guān)機(jī)的vbs腳本
本文地址:http://mengdiqiu.com.cn/a1/vb/7997.html
您可能感興趣的文章
- 01-10vbscript 可以按引用傳遞參數(shù)嗎?
- 01-10Restart.vbs源代碼可以重啟遠(yuǎn)程電腦的vbs
- 01-10利用vbscript腳本修改文件內(nèi)容,此適用于自動化的操作中
- 01-10可以得到當(dāng)前系統(tǒng)信息的腳本sysinfo.vbs
- 01-10利用VBS腳本自動創(chuàng)建計(jì)算機(jī)帳戶的代碼
- 01-10一個可以更換windows xp or 2003的序列號的vbs腳本
- 01-10一個可以刪除指定天數(shù)文件的vbs腳本
- 01-10vbscript自動配置IIS的代碼
- 01-10用vbs實(shí)現(xiàn)定時(shí)運(yùn)行web文件的方法
- 01-10vbs定時(shí)發(fā)送郵件的方法與代碼


閱讀排行
本欄相關(guān)
- 01-10下載文件到本地運(yùn)行的vbs
- 01-10飄葉千夫指源代碼,又稱qq刷屏器
- 01-10SendKeys參考文檔
- 01-10什么是一個高效的軟件
- 01-10VBS中的正則表達(dá)式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一課深入VBScript
- 01-10VBScript語法速查及實(shí)例說明