本帖最后由 pcl_test 于 2016-5-9 01:16 编辑
vbs- Set ws = CreateObject("WScript.Shell")
- Set fso = CreateObject("Scripting.FileSystemObject")
- CommandMode()
- t = InputBox("请输入关机延时秒数(0-315360000):", "提示", 30)
- If t<>"" and t>=0 and t<=315360000 Then
- dt = DateAdd("s", t, now)
- r =t
- ws.run "shutdown -s -t "&t
- Set f = fso.OpenTextFile("CloseTime.txt", 2, True)
- f.Write dt
- f.Close
- For i = r To 1 Step -1
- WScript.Echo "系统将在 "& dt &" 时,"& GetDT(r) &" 后关闭。"
- r = r - 1
- Wscript.Sleep 1000
- Next
- Else
- WScript.Echo "数值错误"
- End If
-
- Function GetDT(t)
- d = int(t / 86400)
- h = int((t mod 86400)/3600)
- m = int((t mod 3600)/60)
- s = t mod 60
- GetDT = d &"天"& h &"时"& m &"分"& s &"秒"
- End Function
-
- Sub CommandMode()
- If InStr(1, WScript.FullName, "\cscript.exe", vbTextCompare) > 0 Then Exit Sub
- Command = "%Comspec% /c cscript.exe //NoLogo """ & WScript.ScriptFullName & """"
- CreateObject("WScript.Shell").Run Command & " & pause", 1, False
- WScript.Quit
- End Sub
复制代码
|