Avatar of Andrew Porter
Andrew Porter
Flag for United States of America

asked on 

Batch File using XCOPY Needs To Skip Machines That Are Offline

I've created a batch file that uses XCOPY to iterate through a list of workstations, and copy files from a server to a collection of workstations.

The batch file works great - unless one of the machines is offline, then the .bat just hangs.

Do any of you experts have an idea as to how I can add some conditional handling that will "test" each workstation for reachability, and if the machine is not online, skip it and go to the next. I've seen ideas to test w/ ping, but I don't know how to implement it.

TEXT FOR BATCH FILE
FOR /F "delims=" %i IN (C:\Automation\Workstations.txt) DO (
xcopy "\\servername\sharename\*.pdf" "%i" /Y)


TEXT FOR WORKSTATIONS.TXT
\\workstation1\c$\abc\dir\
\\workstation2\c$\abc\dir\
\\workstation3\c$\abc\dir\
\\workstation4\c$\abc\dir\
\\workstation5\c$\abc\dir\

* Batchfiles* XcopyWindows OS

Avatar of undefined
Last Comment
NVIT

8/22/2022 - Mon