I am currently writing a Batch file (first time doing so) to remotely call machines in our network (all embedded XP) and schedule a defrag at 11:00PM (23:00).
Of course, it isn’t going as planned, that is understandable. However, I would like to get the logging information that would typically be given at command prompt, such as ‘disk is -% defragmented’ or errors, etc. My current stage of the line that makes the call is this:
@FOR /F "Tokens=1" %%a IN (%List%) DO at \\%%a 23:00 defrag C: /A > C:\...\log.txt
NOTE: The ellipsis in between C:\ and \defraglog.txt actually have the full pathname typed. For context, %List% is a list of IP addresses.
However, defrag never even launches. According to the remote computer I am testing on, the command looks like:
defrag C: /A and C:\...\log.txt
when I look at Scheduled Tasks.
Now, when I simply use:
@FOR /F "Tokens=1" %%a IN (%List%) DO at \\%%a 23:00 defrag C:
I do get a defragmentation scheduled at 11:00PM on the remote machines, so I am assuming the issue lies in the way I am redirecting.
Any help would be greatly appreciated!
I would try adding quotes:
If that doesn’t work, make a batch file defragXP.cmd on a network share that holds:
and then schedule the batch: