I wrote a short batch file for restarting two services every night and write some lines to a txt-file in the same folder. According to the history of the scheduled task the task ran succesfully, but the txt-file is not created.
At first I thought this was beacause of permissions, but when I escalated the permissions of the user running the task to max on both the batch file and the folder, the result stayed the same.
If I run the batch-file manually it does what it's supposed to do.
What am I missing here?
Source:
@echo off
set now=%date:~6,4%%date:~3,2%%date:~0,2%
@echo. >>servicerestartlog.txt
@echo.%now% >>servicerestartlog.txt
net stop "IntegratorService"
IF ERRORLEVEL 0 @echo STOP INTEGRATOR SUCCESS>>servicerestartlog.txt
IF NOT ERRORLEVEL 0 @echo STOP INTEGRATOR FAILED>>servicerestartlog.txt
net stop "SchedulerService"
IF ERRORLEVEL 0 @echo STOP SCHEDULER SUCCESS>>servicerestartlog.txt
IF NOT ERRORLEVEL 0 @echo STOP SCHEDULER FAILED>>servicerestartlog.txt
net start "IntegratorService"
IF ERRORLEVEL 0 @echo START INTEGRATOR SUCCESS>>servicerestartlog.txt
IF NOT ERRORLEVEL 0 @echo START INTEGRATOR FAILED>>servicerestartlog.txt
net start "SchedulerService"
IF ERRORLEVEL 0 @echo START SCHEDULER SUCCESS>>servicerestartlog.txt
IF NOT ERRORLEVEL 0 @echo START SCHEDULER FAILED>>servicerestartlog.txt
exit