|
Answer» I'm trying to figure out a means to copy a single file from one location on to multiple workstations, but because the workstation names might change I want to put the names in a text file for the batch to take to plunk into the command.
Something like
:start get computername starting with line 1 from text file :process xcopy C:\filename.txt \\%computername%\folder get next computername from text file if last computername goto end goto process :end
(robocopy might WORK better for this instead of xcopy)
In the text file will have one column like:
abc abb acc etc...
Any sort of pointers would help greatly. Something along these lines perhaps?
Code: [Select]for /f "delims==" %%A in (file.txt) do ( xcopy c:\filename.txt \\%%A\folder )
This FOR loop reads each line in turn from a text file called file.txt and substitutes that line for the computername in the xcopy command which is then executed That SEEMS to work. Thanks!
I tested this for another task, to rename a folder on muliple workstations and did it for one and worked like a charm. I'll do the file copy next once I get this task done...
Now I just need to figure out 'upon ERROR' goto next computer in case the pc is down and somehow report the missing computer.Quote from: Relig on September 04, 2009, 04:59:17 PM Now I just need to figure out 'upon error' goto next computer in case the pc is down and somehow report the missing computer.
what you could try and do is ping each computer and use the errorlevel to tell if the system is on or not. if the system is off then echo the computer name into a text file on the host (the system the batch is running on).
|