closehauled
asked on
Batch file to test if scheduled task last result= 0x0
Hi Experts,
Can anyone give me a batch file if statement to check last result of a scheduled task.
We use a scheduled task batch file that renames and moves backup files but it copies over good backups with bad ones.
I'd like to test if last resullt = 0x0 prior to the copy to ensure I don't loose good backups.
Thanks,
Scott
Can anyone give me a batch file if statement to check last result of a scheduled task.
We use a scheduled task batch file that renames and moves backup files but it copies over good backups with bad ones.
I'd like to test if last resullt = 0x0 prior to the copy to ensure I don't loose good backups.
Thanks,
Scott
Correction:
for /F "tokens=2 delims=:" %%R in ('schtask /query /v /FO list /TN "Taskname" /v ^| findstr /i result') do set /A result=%%R
ASKER
Thanks for getting back to me on this.
The /tn "taskname" parameter seems not valid for /query also had to use schtasks.
The /tn "taskname" parameter seems not valid for /query also had to use schtasks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, it works a charm.
for /F "tokens=2 delims=:" %%R in ('schtask /query /TN "Taskname" /v ^| findstr /i result') do set /A result=%%R
with "Taskname" replaced by the task you want to check.