mirror of
https://github.com/NewFuture/DDNS.git
synced 2022-04-19 20:24:44 +00:00
Windows Task Scheduler is not CMD, the redirecting operator '>>' can only effect in CMD. So the operator will cause '0x2' error in Windows Task Scheduler. My last commit https://github.com/NewFuture/DDNS/pull/208/commits/8ea0d5976de4a668e973e19548c8f2315f7b930f will force add the redirecting to the Win TS due to the double quotes in ```RUNCMD```, while the previous commit did not add redirecting to Win TS as expected and the log file was always empty. One solution in this commit is to change the running program in Win TS from ddns.exe to cmd, then run ddns.exe in cmd. So that the Task can run as scheduled and the log can also be redirected.
13 lines
380 B
Batchfile
13 lines
380 B
Batchfile
@ECHO OFF
|
|
REM https://msdn.microsoft.com/zh-cn/library/windows/desktop/bb736357(v=vs.85).aspx
|
|
|
|
SET RUNCMD="cmd /c ''%~dp0ddns.exe' -c '%~dp0config.json' >> '%~dp0run.log''"
|
|
|
|
SET RUN_USER=%USERNAME%
|
|
WHOAMI /GROUPS | FIND "12288" > NUL && SET RUN_USER="SYSTEM"
|
|
|
|
ECHO Create task run as %RUN_USER%
|
|
schtasks /Create /SC MINUTE /MO 5 /TR %RUNCMD% /TN "DDNS" /F /RU "%RUN_USER%"
|
|
|
|
PAUSE
|