• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3220
  • Last Modified:

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.
0
jasonx09
Asked:
jasonx09
  • 3
1 Solution
 
Grizzly072000Commented:
Use robocopy instead. Much better tool than xcopy.
0
 
oBdACommented:
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:

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
 )
)

Open in new window

0
 
Grizzly072000Commented:
@oBdA: Single file? Then why xcopy? copy is plenty.

Some robocopy options that might solve the OP's problem:

          /R:n : number of Retries on failed copies - default is 1 million.
          /W:n : Wait time between retries - default is 30 seconds.
          /TBD : Wait for a sharename to be created by retrying on error 67
          /Z : Copies files in restartable mode.
0
 
jasonx09Author Commented:
I'm not sure that I understand the find portion of the solution but it works well. It took the wait for the timeouts from 20 seconds to 10 seconds. I also added the -w switch to specify the timeout as 240 mil. This took the time down to 5 seconds per failure. Thank you for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now