Question : Change xcopy timeout setting

I am running a script that uses the xcopy command to add a scheduled task to several workstations. This is the script.
for /F %%G in (computers.txt) do (
 xcopy defrag.job \\%%G\admin$\tasks\ /C /H /R /Y
 schtasks /change /s %%G /RU "NT AUTHORITY\SYSTEM" /tn Defrag
)
When workstations are not on the timeouts cause the script to take too long to complete. How can I change the timeout to a shorter setting to speed up the processing of the script.

Answer : Change xcopy timeout setting

robocopy is basically better indeed, but we're just talking about a single file here, and even robocopy will have to wait for the redirector's response when trying to access the remote machine.
Simply ping the machine before you actually start the copy:
1:
2:
3:
4:
5:
6:
7:
8:
9:
for /F %%G in (computers.txt) do (
 ping %%G | find /i "TTL" >NUL
 if errorlevel 1 (
  echo ... no response
 ) else (
  xcopy defrag.job \\%%G\admin$\tasks\ /C /H /R /Y
  schtasks /change /s %%G /RU "NT AUTHORITY\SYSTEM" /tn Defrag
 )
)
Random Solutions  
 
programming4us programming4us