Make robocopy skip offline computers in text-file

1

I'm trying to write a batch file that will robocopy a msi file from a server to all the domain PCs that are online at that time. It should skip PCs that already have the file listed and PCs that are offline.

Currently I'm using this.

for /f %%i in (\\domain.lan\folder\folder\computers.txt) do robocopy c:\software\msifolder \\%%i\c$\install /MIR

After that I'm using psexec to open a CMD on the target PC and run the MSI with msiexec

psexec \\computername.domain.lan -u domain\"Username" -p "Password" cmd >> \domain.lan\folder\folder\software.install.txt 2>&1
msiexec.exe /quiet  /i c:\install\software.msi /norestart

The idea is to let this script run as a task for a week to install a program on as many PCs as possible unattended.

The psexec and msiexec are working fine. But the robocopy keeps retrying to access PCs that are offline. It should just skip to the next computer.

I tried to include as much info as possible. Let me know if you need more info.

Maarten

Posted 2017-06-01T16:27:04.210

Reputation: 21

1Try and ping em, if no response, don't do the robocopy – djsmiley2k TMW – 2017-06-01T16:30:30.230

Answers

0

Add the /W and /R switches to your RoboCopy command.

Per TechNet:

/r:<N>    Specifies the number of retries on failed copies.
          The default value of N is 1,000,000 (one million retries).

/w:<N>    Specifies the wait time between retries, in seconds.
          The default value of N is 30 (wait time 30 seconds).

So the command:

robocopy c:\software\msifolder \\%%i\c$\install /MIR /R:1 /W:1

Would retry once after a one second interval, then abandon the copy if the remote machine is offline.

I say Reinstate Monica

Posted 2017-06-01T16:27:04.210

Reputation: 21 477

This was very helpful. Works like a charm. – Maarten – 2017-06-06T10:23:35.780

Glad it worked. Be sure to upvote/accept the answer accordingly. – I say Reinstate Monica – 2017-06-06T11:56:27.187