I need to create a bat file to copy a single file to all my networked systems. I have a text file with all the systems names. How can I pull that into a bat file to as the copy destination?
If so, you can just do a multiple edit on your file (if you first ensure there's a character before the system name and a different one after (eg, space and .) - some like replace space with 'xcopy filename \\'
Then replace . with '\sharename\folder'
If the sharenames are all different, but the actual location on each machine is same (eg, C:\documents and settings\All Users\Start Menu), you might want to look at psexec (part of pstools at
*******************************************
@echo off
for /F %%I in (<xx>) do copy <file> \\%%I\<destination>
*******************************************
where
<xx> is the file containing your machine names with 1 name per line
<file> is the file to copy
<destination>is the path on each machine to copy to
( or something like that... you might have to work out the copy bit for yourself )
For a safer test first do
*******************************************
@echo off
for /F %%I in (<xx>) do echo copy <file> \\%%I\<destination>
*******************************************
to check what your output will be before actually doing the copy!!..
Jocsta, this is just what I needed. If I use your commands from a dos prompt it works great and says 1 file copied. If I let it run from the bat file it just returns to the command prompt with no indication the file copied. When I check system the file is not there.
Groucho said it best- "A four year-old child could understand this! Quick! Run out and find me a four year-old child: I can't make heads nor tails out of this!"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.