I've written a batch file that checks if Hamachi Service is working and if it is not it starts it. I made this script working in background by writing vbs script
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
and executing it
wscript.exe "invisible.vbs" "HamachiRestart.bat"
HamachiRestart.bat looks like this:
for /F "tokens=3 delims=: " %%H in ('sc query "Hamachi2Svc" ^| findstr " STATE"') do (
if /I "%%H" NEQ "RUNNING" (
net start "Hamachi2Svc"
echo %COMPUTERNAME% %DATE% %TIME% :: Uruchomiono usługę >> LOG.txt
)
)
echo %COMPUTERNAME% %DATE% %TIME% :: OK >> LOG.txt
exit
and when I'm executing it from console it is working fine (restart service and add line to log) but main problem is that when I try to schedule it in Windows Task Scheduler it is working partially (restart service but log is empty...)
Any ideas how to fix it? I just need this log file working.