user2819161
user2819161

Reputation: 49

unable to execute a batch file from the task scheduler

I am struggling with this since yesterday, i have created a Batch file -a simple one- which simply will try to read the logs of a windows scheduled task and based on searching for correct 'Last result' will log 0 or 1 to a log file . The Batch file run perfectly . But i want to schedule this Batch file to be ran each 2 minutes ,

so i create a scheduled task that ran this batch file ;When i force starting the scheduled task, I don't see any errors in the task scheduler history, but at the same time my Batch file is not executed.

What i tried, -i made sure i am running the scheduled task with option "run with highest privileges" , -i made sure i have correct permissions (still not sure) I tried using process monitor and didn't see any access issues so nothing happens when i run my task i am going crazy,

This is the content of my Batch file :

     SET LOGFILE=MyLogFile.log
    call :Logit >> %LOGFILE% 
    exit /b 0

:Logit :: The rest of your code :: .... for %%A in (DownloadToIngest.log) do set fileSize=%%~zA echo %fileSize%>logall.log if %fileSize% GTR 419430400 (break>DownloadToIngest.log) schtasks /QUERY /FO LIST /V /tn DownloadToIngest> DownloadToIngestOutput.log findstr /m "Last Result: 0" DownloadToIngestOutput.log IF %errorlevel%==0 (>>DownloadToIngest.log echo 1) ELSE >>DownloadToIngest.log echo 0<code>

Upvotes: 0

Views: 2062

Answers (1)

user2819161
user2819161

Reputation: 49

Thanks Vector (Look Vector's comment) , the issue was solved by : instead of referencing the path and file name under 'Program/script' adding the name of script under 'Program/script' and the path to the file under 'Start in (optional)'

Upvotes: 1

Related Questions