Automatically copy a file to multiple remote Windows XP clients


The following example shows you how to copy a file to multiple Windows computers using a simple batch file and taking advantage of the built in c$ share that Windows computers have. In my example I will attempt to copy the file called myexample.file to the root of the c: directory on the following Windows XP computers pc01, pc02, pc03, pc04. The script will use to do it I will name remotecopy.cmd Bear in mind that this example expects the c$ share to exist on each of the remote pcs – this is not always the case in many organisations who may have switched the built in administrative shares off. Also this example refers to Windows XP but it will work on other versions of Windows that have the c$ share also.

Create the Script (remotecopy.cmd)

1. Logon to your PC with a user which has suitable permissons to access to your remote computers administrative shares. This would normally be a domain adminstrator level account.   2. Create a directory called c:\scripts 3. Create the file called myexample.file. This can be an empty or 0 byte file. 4. Create a file under this scripts directory called hostnames.txt 5. Populate the hostnames.txt with the list of all the remote computers you wish to copy the file to. Each hostname should be on a line of its own like so;

PC01
PC02
PC03
PC04

6. Now create a the actual script which does the work. I am calling it remotecopy.cmd.  It should look like this

@rem simple copy script for Windows Command Interpreter (cmd.exe)
@echo Read in each hostname entry in the file hostnames.txt amd copy the local file to the c$ of each hostname

FOR /F  %%i in (hostnames.txt) do copy myfile.txt \\%%i\c$

Run the script

1. Open a Command Prompt Window Start->Run->cmd 2. Navigate to the c:\scripts directory

   c:\
   cd \scripts

3. Type remotecopy.cmd 4. Watch the script (hopefully) run! If all goes well the script will loop through each of the computer hostnames in the file and copy the file across.   In this example we use 4 remote pcs which for most people it might be less hassle to copy the file across manually however if you have over 15 or so PCs it gets a bit more of a pain.  Reading the the pcs from a text f ile and then scripting the copy is a less painful way of doing a mass copy.  Of course creating the text file is a bit tedious also, having to input all of those computer names in manually.  You can have a go at grabbing them using these instructions here Import Windows hosts in domain how to

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: