paip. 定时 关机 休眠 的总结
paip. 定时 关机 休眠 的总结
//////////////////title
bat shell 批处理日期时间的使用比较.
bat shell 批处理if else 多行..
作者Attilax 艾龙, EMAIL:1466519819@qq.com
来源:attilax的专栏
地址:http://blog.csdn.net/attilax
流程
1.显示msg
2.休眠.. rundll32 powrprof.dll,SetSuspendState
3.两种方式保证达到.
4.计划任务调用.保证不要登录的情况哈也能调用.
但是.WIN7 的 计划任务有个缺点..过了时间还会执行..造成.早晨启动机器时候还会休眠..
改进:调用自己编程的程序,判断时间...过期不在执行..
////////////////java 方式
java -Djava.ext.dirs="C:\Users\Administrator\Workspaces\MyEclipse 8.5\homiSearchServer\WebRoot\WEB-INF\lib" -classpath "C:\Users\Administrator\Workspaces\MyEclipse 8.5\homiServerm\bin;" m.autoshutdown 19:40 "f:\shut\shut.log"
public static void main(String[] args) {
final String shutdown_time = args[0].trim();// 14:14
final String ShutLog =args[1];
final String cmdShutdown = "rundll32 powrprof.dll,SetSuspendState";
new HashSet() {
public Object callMethod(Object obj) {
// n++;
if (dateUtil_o16.isNotGocyi(10,shutdown_time)) {
FileService.FileAppend("shut now...“+ new Date()+”\r\n", ShutLog);
shutdown();
} else {
FileService.FileAppend("chaosi ..." + new Date() + "\r\n", ShutLog);
}
return null;
}
private void shutdown() {
try {
cmdx.exec(cmdShutdown);
} catch (IOException e) {
e.printStackTrace();
}
}
}.callMethod("");
}
//////////////////////bat方式
%time%
set exec=rundll32 powrprof.dll,SetSuspendState
set log=f:\shut\shut_batx.log
#%execxx%
@echo %time:~0,2%
@if %time:~0,5% lss 19:15 (
if %time:~0,5% gtr 19:05 (
rem echo msg start_hb
rem start "start to shut down after 5min "
rem sleep wait 5min
echo "shut aft 5 min " %date% %time% >>%log%
choice /t 300 /d y
echo " shut by bat now..." %date% %time% >>%log%
%exec%
) else (echo "less1905 only 1905---1915---" %date% %time% >>%log%)
) else (echo " grter than 1915 " %date% %time% >>%log% )
:wait_down
exit
//////////////////title
bat shell 批处理日期时间的使用比较.
bat shell 批处理if else 多行..
作者Attilax 艾龙, EMAIL:1466519819@qq.com
来源:attilax的专栏
地址:http://blog.csdn.net/attilax
流程
1.显示msg
2.休眠.. rundll32 powrprof.dll,SetSuspendState
3.两种方式保证达到.
4.计划任务调用.保证不要登录的情况哈也能调用.
但是.WIN7 的 计划任务有个缺点..过了时间还会执行..造成.早晨启动机器时候还会休眠..
改进:调用自己编程的程序,判断时间...过期不在执行..
////////////////java 方式
java -Djava.ext.dirs="C:\Users\Administrator\Workspaces\MyEclipse 8.5\homiSearchServer\WebRoot\WEB-INF\lib" -classpath "C:\Users\Administrator\Workspaces\MyEclipse 8.5\homiServerm\bin;" m.autoshutdown 19:40 "f:\shut\shut.log"
public static void main(String[] args) {
final String shutdown_time = args[0].trim();// 14:14
final String ShutLog =args[1];
final String cmdShutdown = "rundll32 powrprof.dll,SetSuspendState";
new HashSet() {
public Object callMethod(Object obj) {
// n++;
if (dateUtil_o16.isNotGocyi(10,shutdown_time)) {
FileService.FileAppend("shut now...“+ new Date()+”\r\n", ShutLog);
shutdown();
} else {
FileService.FileAppend("chaosi ..." + new Date() + "\r\n", ShutLog);
}
return null;
}
private void shutdown() {
try {
cmdx.exec(cmdShutdown);
} catch (IOException e) {
e.printStackTrace();
}
}
}.callMethod("");
}
//////////////////////bat方式
%time%
set exec=rundll32 powrprof.dll,SetSuspendState
set log=f:\shut\shut_batx.log
#%execxx%
@echo %time:~0,2%
@if %time:~0,5% lss 19:15 (
if %time:~0,5% gtr 19:05 (
rem echo msg start_hb
rem start "start to shut down after 5min "
rem sleep wait 5min
echo "shut aft 5 min " %date% %time% >>%log%
choice /t 300 /d y
echo " shut by bat now..." %date% %time% >>%log%
%exec%
) else (echo "less1905 only 1905---1915---" %date% %time% >>%log%)
) else (echo " grter than 1915 " %date% %time% >>%log% )
:wait_down
exit