1.Reboot重启脚本(reboot.bat):
@echo off
setlocal
cd/d %temp%
echo [version] > reboot.inf
set inf=InstallHinfSection DefaultInstall
echo signature=$chicago$ >> reboot.inf
echo [defaultinstall] >> reboot.inf
rundll32 setupapi,%inf% 1 %temp%\reboot.inf
del reboot.inf
2.关机脚本(shutdown.bat):
@echo off
setlocal
cd/d %temp%
echo Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem") >shutdown.vbs
echo For Each objOperatingSystem in colOperatingSystems >>shutdown.vbs
echo ObjOperatingSystem.Win32Shutdown(8) >>shutdown.vbs
echo Next >>shutdown.vbs
cscript shutdown.vbs
del shutdown.vbs
3.关机脚本(shutdown1.vbs):
Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(8)
Next
4.延时60秒,在关机前提示,可以在延时到达前取消关机(shutdown2.vbs脚本):
set wshshell = CreateObject("WScript.Shell")
timeout = 60
'Time Out 可以自己定义
ask = "系统将在 " & timeout & " 秒钟后关机!"
title = "自动关机提示"
constants = vbExclamation + vbOkCancel
result = wshshell.Popup(ask, timeout, title, constants)
if result = vbCancel then
elseif result = true then
Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(8)
Next
end if
提示1:上面的脚本保存为相应的文件即可直接运行,亦可放于计划任务中定时执行。Win32Shutdown()中的参数为1时,不会彻底断电,而会显示:现在您可以安全地关闭计算机了。
提示2:上面关机脚本,比如shutdown1.vbs放于系统的system32目录;点击“开始”,运行control, 进入:“任务计划“,点击邮件,新建计划任务,取名为shutdown,右击shutdown图标,点属性,运行一栏浏览到C:\WINNT\system32\shutdown2.vbs,确定,属性的日程安排中,设置计划任务空闲时运行,并设置空闲时间即可。
本文地址:http://com.8s8s.com/it/it35216.htm