Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Bat file to copy a file to all my networked systems 4

Status
Not open for further replies.

Scottncs

IS-IT--Management
Jun 13, 2002
29
0
0
US
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?
 
Is it going to same place on each machine? Do all machines have same sharename for destination drive/folder? (or where destination folder lives)

so for example

\\machine1\sharename\folder
\\machine2\sharename\folder

etc

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 to submit jobs to run on each machine - something like:

psexec -u Administrator -p password -d \\machine1 xcopy \\server\filename "C:\documents and settings\All Users\Start Menu"
psexec -u Administrator -p password -d \\machine2 xcopy \\server\filename "C:\documents and settings\All Users\Start Menu"

etc, using multiple edit again, before and after system/machine name.

Hope this helps (& is not too confusing)
 
If you wanna do it in a batch file:-

*******************************************
@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!!..

<< JOC >>
 
Thanks.....
Gimme a command prompt and I will rule the world! 8D
 
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.
 
Best guess is that you are not using the full path for the <xx> and <file> parts.
<< JOC >>
 
Thanks, Jocsta! Wolluf suggested that I check some of your posts, and sure enough--I found the help that I needed!

I won't bore you with details, but reading through your For statements really fixed a problem (that I was trying to over complicate).

Thanks again! Mudskipper
___________________________________________________________________________________

Groucho said it best- &quot;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!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top