设置计划任务,我们使用:
REM SET THE DATE WE WANT THE TASK TO RUN
SET STARTDATE=12/06/2015
SCHTASKS /S SERVER /CHANGE /TN "SERVICE_RESTART" /RU "" /DISABLE
SCHTASKS /S SERVER /F /CREATE /TN "SERVER_RESTART" /RU "" /RP "" /SC ONCE /ST:02:11 /SD %STARTDATE% /TR "D:\WORK\scripts\Server_Reboot.bat 1"
编写了以下Windows批处理脚本,并且在昨晚运行时遇到了一些问题..
@echo off
SET /A ARGS_COUNT=0
FOR %%A in (%*) DO SET /A ARGS_COUNT+=1
rem ECHO %ARGS_COUNT%
If %ARGS_COUNT% == 0 goto leave
If %ARGS_COUNT% == 1 goto continue
:continue
echo we would restart here
SCHTASKS /CHANGE /TN "SERVICE_TCRESTART" /ENABLE /RU ""
SCHTASKS /CHANGE /TN "SERVER_RESTART" /DISABLE /RU ""
shutdown /r /t 0 /c "scheduled reboot" /f /d P:0:0
goto end
:leave
echo we are done
goto end
:end
echo bye
注意:脚本必须运行:" Server_Reboot.bat 1" - 我不确定是否必须安排使用带引号的Windows 2003重启服务器? Windows 2008系统似乎没问题/
找到了Windows Shutdown的替代品,我想知道是否需要使用它而不是shutdown.exe:
WMIC OS Where Primary=TRUE Call Reboot
谢谢!
答案 0 :(得分:0)
我想我自己想到了args部分......
我们在Tomcat Zip service.bat文件中获得了一些帮助..
@echo off
if "%1" == "" goto Leave
if %1 == reboot goto continue
:continue
echo we would restart here
SCHTASKS /CHANGE /TN "SERVICE_TCRESTART" /ENABLE /RU ""
SCHTASKS /CHANGE /TN "SERVER_RESTART" /DISABLE /RU ""
shutdown /r /t 0 /c "scheduled reboot" /f /d P:0:0
goto end
:leave
echo we are done
goto end
:end
echo bye