Copy file to multiple computers


I want to copy a file called xyz.bmp to the c: folder of a list of computers i have on a text file.
I'm in a domain environment without about 50 desktops. My domain user account is the local administrator on all these machines.

I understand the best logical way, is to run a batch file that will read from this text file that hass all the computer name, and execute the copy command for all the computers in the text file.
This is the logic, but I don't have any scripting know how. Could some one please explain how this can be done from scratch?

Thanks in advance

Who is Participating?
Put the file in an open share.....
Text file atc:\PCNames.txt

PsExec v1.94

psexec @pcnames.txt -d copy /Y "\\server\share\xyz.bmp" c:\

-d switch is optional, it just moves on to the next PC name in the list without waiting for the first one to complete....
Do You have a GPO that applies to all the computers, you can add a startup script that will have
copy \\server\share\filename c:\

You could introduce a check to see if the file is present before issueing the copy command.
When the system boot the script will run with system rights and will check whether the file is present if it is missing, it will copy the one from the share.
Use this script, save it as C:\Copy.vbs and call it as such from a cmd window.


cd \

cscript Copy.vbs <file> <location> <machinelist>

Option Explicit
Dim sFileToCopy
Dim sLocationToCopy
Dim sLocationSplit
Dim lPos
Dim sDriveToCopy
Dim sFolderToCopy
Dim sServerList
Dim sList
Dim oFSO
Dim oStream
Dim X
Dim sLog
Dim lErrors
Dim lSuccess
Set oFSO = CreateObject( "Scripting.FileSystemObject" )
lErrors = 0
lSuccess = 0
sLog = ""
If WScript.Arguments.Count <> 3 Then
	Wscript.Echo ("Usage: " & vbcrlf & vbcrlf & "cscript " & Wscript.ScriptName & " ""C:\Example.exe"" ""C:\Location"" ""C:\ServerList.txt""")
End If
sFileToCopy = WScript.Arguments.Item(0)
sLocationToCopy = WScript.Arguments.Item(1)
sServerList = WScript.Arguments.Item(2)
lPos = Instr( sLocationToCopy, ":" )
If ( lPos < 1 ) Then
	Wscript.Echo ("Invalid format for desitantion location.")
ElseIf Not oFSO.FileExists( sFileToCopy ) Then
	Wscript.Echo ("Invalid file specified: " & sFileToCopy )
ElseIf Not oFSO.FileExists( sServerList ) Then
	Wscript.Echo ("Invalid server list specified: " & sServerList )
End If
Set oStream = oFSO.OpenTextFile( sServerList )
sList = Split( oStream.ReadAll, vbCrLf )
sDriveToCopy = Left( sLocationToCopy, lPos - 1 )
sFolderToCopy = Right( sLocationToCopy, Len(sLocationToCopy) - lPos )
On Error Resume Next
For X = 0 To UBound( sList )
	sLocationToCopy = "\\" & sList(X) & "\" & sDriveToCopy & "$" & sFolderToCopy
	If Not oFSO.CopyFile ( sFileToCopy, sLocationToCopy, True )  Then
		lErrors = lErrors + 1
		If Err Then
			sLog = sLog & vbCrLf & vbCrLf & "CopyFile( '" & sFileToCopy & "', '" & sLocationToCopy & "' ) ERROR - " & sList(X) & " - " & Err.Description
			sLog = sLog & vbCrLf & vbCrLf & "CopyFile( '" & sFileToCopy & "', '" & sLocationToCopy & "' ) ERROR - " & sList(X) & " - Unknown Error!"
		End If
		lSuccess = lSuccess + 1
	End If
MsgBox( "Processed: " & lSuccess & vbCrLf & "Failed: " & lErrors)
If lErrors > 0 Then
	Wscript.Echo ("Error Log: " & vbCrLf & sLog )
End If 

Open in new window

And no scripting needed... Thats the main reason I suggest this. Takes local commands, and makes them available to use remotely....
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.