1.

Solve : Library in need of help with batch script?

Answer»

Hello,

I am hoping someone can help me get started with a batch script needed for our LIBRARY.

What I need to do is copy a file to all of our systems.

I have a LIST of computernames in a file called systems.txt
The filename I need to copy is diskclean.bat

So the basics of what I am trying to accomplish is to read the system names in from systems.txt and then copy diskclean.bat to that system...the copy command would equate to something like copy \\librsbpct\ c:\diskclean.bat of course librsbpct being replaced by a variable.....

Once someone can get me started, I am pretty good at modifying the script for my needs after that. Thanks in advance to anyone who can give me a hand.Assuming there is only one system name per line in your system file. this may help:

Code: [Select]for /f "tokens=*" %%i in (systems.txt) do (
copy c:\diskclean.bat \\%%i\
)

On each loop of the FOR, the variable %%i holds each system name from the file; you may need to improve on the output path.

Hope this helps. 8-)I HESITATE to suggest the obvious,

Make a copy of your library txt file
Rename it xxx.BAT
Edit it and change all lines to be copy commands.

Easy to tailor to special cases, etc.

But if this is a homework assignment and not a practical problem, never mind.

Mac
If you need to copy the file from your local PC / Server to all the computers in the systems.txt file, I think you need something like (very similar to Sidewinders post):
Code: [Select]for /f %%a in (systems.txt) do (
copy diskclean.bat \\%%a\C$
)The PC / Server / user account will need administrative RIGHTS to the other computers.Thanks to both of you for QUICK and accurate info!

I think gurugary gave me a piece of the puzzle that I was shooting towards but hadnt figured it out. I do not have a share on each and every machine, therefore the following would not work.

copy diskclean.bat \\librsbpct\

The thought of the administrative hidden shares had crossed my mind, but i hadnt tested it and didnt remember how to access them...

i did an initial test of the script with the hidden share of C$ and it worked like a charm!

May good karma come your way!



Discussion

No Comment Found