• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2992
  • 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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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