A few months ago, I posted a question about using a script that would run against all the in a list. I wanted it to schedule a defrag at the end of the current work day, and continue to run every 6 months thereafter.
1. quarterly - I now need to change it to quarterly and am running into difficulty.
2. re-run script OK - I would also like to further ensure that if the script is re-run against the same machine, that it replaces the previous tasks named defrag. I think this happens as-is but am not quite certain.
3. ignore error - Most importantly, I would like the script to continue through the list regardless of any problems that might have been experienced with one machine. If it doesn't find something with a machine, It should continue through the list regardless.
Any help with the script pasted below is greatly appreciated.
Set TaskRun="cmd /c defrag c: -f"
Set RecurRun=monthly /mo 3 /tn "Quarterly defrag"
For /f %%a in (c:\computers.txt) do (
schtasks /create /s %%a /ru system /sc once /tn "One time defrag" /st %TimeToRun% /tr %TaskRun%
schtasks /create /s %%a /ru system /sc monthly /mo 3 /tn "Quarterly defrag" /st %TimeToRun% /tr %TaskRun%