Asked by:
Script to restart a failed batch file

General discussion
-
I have tasked to write a script that when a batch job fails which causes the computer to reboot, that powershell will restart the failed job, and append to the log files that the job was originally writing to. Does someone already have a script that does something similar to this?
- Changed type Bill_Stewart Monday, July 30, 2018 1:43 PM
- Moved by Bill_Stewart Monday, July 30, 2018 1:43 PM This is not "scripts on demand"
Thursday, June 7, 2018 2:53 PM
All replies
-
I have been tasked with writing a script that will restart a failed batch job that writes output to a file. When the batch job is restarted, the task is then that the output will be appended to the existing output file and not overwrite it. Has anyone written a script similar to that?
- Merged by Bill_Stewart Thursday, June 7, 2018 8:11 PM Duplicate
Thursday, June 7, 2018 4:52 PM -
Use Register-ScheduledJob to persist a job across reboots.
You can also use a Workflow with checkpoints
\_(ツ)_/
Thursday, June 7, 2018 4:56 PM -
Thursday, June 7, 2018 4:58 PM
-
This is not a script request forum. Please read the following:
This forum is for scripting questions rather than script requests
-- Bill Stewart [Bill_Stewart]
Thursday, June 7, 2018 9:15 PM -
jrv ... for the register-scheduled job, does that also work with batch files?
Here's a snippet of my code so far:
Start-job C:\AutoRunFio\Knobs\Default\RestoreToDefault.bat -wait Start-job C:\AutoRunFio\Knobs\Battery\Knob.bat -wait Start-job C:\AutoRunFio\Knobs\Default\RestoreToDefault.bat -wait
Friday, June 8, 2018 4:09 PM -
Did you read the links I posted?
You would not design any solution the way you have done this. Why have multiple jobs for one sequential process.
Also the code would have to be redesigned to make it restartable. This would indicate that converting the batch files to PwoerShell might be the best option.
\_(ツ)_/
Friday, June 8, 2018 4:22 PM