Solved

Copy file script

Posted on 2011-02-15
13
963 Views
Last Modified: 2012-05-11
I need to create to scripts iin a classroom. Both scripts are essentially the same. I need to copy a config file from 1 pc to a location on 20 other pc's. I just wanted to know if I have to copy from source to destination for each pc or if I can have 1 copy from source to multiple destinations. Any ideas would be great.
0
Comment
Question by:j8547
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +2
13 Comments
 
LVL 84

Expert Comment

by:oBdA
ID: 34899657
There are several possibilities to run this in a more or less simple script for all machine.
Easiest one: create a file with the names of the 20 "other" PCs (one name per line), for example MachineFile.txt.
Then run something like this in a command prompt in the directory with the list:
for /f "delims=" %a in ('type "MachineList.txt"') do copy "C:\Source\file.txt" "\\%a\C$\Target\Location

If you want to save this as a batch script, double up on the percebt signs:
for /f "delims=" %%a in ('type "MachineList.txt"') do copy "C:\Source\file.txt" "\\%%a\C$\Target\Location

There are other possibilities as well. Do the "other" PCs have a consistent, numeric, naming convention (pc01, pc02, ..., pc20)?
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34899658
You have to call copy for each destination pc by UNC names with hostnames or ips...

copy config.txt \\pc01\c$\configDir\config.txt
...
copy config.txt \\pc20\c$\configDir\config.txt


You can also use ip address:

copy config.txt \\192.168.65.1\c$\configDir\config.txt
...
copy config.txt \\192.168.65.20\c$\configDir\config.txt


0
 

Author Comment

by:j8547
ID: 34899696
I can't use IP address but the pc names range from ...b1 to ...b20

I will try themn out now
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 84

Expert Comment

by:oBdA
ID: 34899747
With these names, you don't even need a machine list. Just use
for /L %i in (1, 1, 20) do copy "C:\Source\file.txt" "\\...b%i\C$\Target\Location
0
 

Author Comment

by:j8547
ID: 34900014
I am getting the system cannot find the path specified yet the paths look correct. Any ideas???
0
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 34900080
The closing quotes in the target folder are missing, that could be the issue.
Otherwise, please copy and paste the output of
for /L %i in (1, 1, 20) do @ECHO copy "C:\Source\file.txt" "\\...b%i\C$\Target\Location"
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34900166
You may create a share folder in the main server, create a file with the twenty computer names and use psexec : http://technet.microsoft.com/en-us/sysinternals/bb896649
to run a copy from all the computer to get the file(s) from the main server.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34900201
0
 
LVL 3

Expert Comment

by:symmcom
ID: 34900235
Assuming you are the administrator and trying to copy the file from the Server to your 20 client computers, simplest form would be:
1. Create a Batch file (anyname.bat)
2. Inside the Batch file type - copy SourceDrive\Thefile.xyz \\ClientPCName\c$\Folder
3. Copy paste this command 19 other times and change the ClientPCName to correct name

This should copy the file to all destination.
0
 

Author Comment

by:j8547
ID: 34901285
It was the quotes. Thanks it is working perfectly now.
0
 

Author Comment

by:j8547
ID: 34901292
Sorry also does the person have to be an admin or can this script use an admin account?????
0
 
LVL 84

Expert Comment

by:oBdA
ID: 34901415
Currently, it has to be an admin due to the administrative share.
If you want this to be run by a regular user, it's safest to share the target folder (with Full Access share permissions for Everyone), and give the "copy" user Change permissions on the target folder.
0
 

Author Comment

by:j8547
ID: 34901422
Thanks
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question