• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1896
  • Last Modified:

Copy file to multiple computers

Hi,

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

CV.
0
connelvalentine
Asked:
connelvalentine
  • 2
1 Solution
 
arnoldCommented:
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.
http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_23983934.html
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.
0
 
c0ldfyr3Commented:
Use this script, save it as C:\Copy.vbs and call it as such from a cmd window.

c:

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""")
	Wscript.Quit
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.")
	Wscript.Quit
ElseIf Not oFSO.FileExists( sFileToCopy ) Then
	Wscript.Echo ("Invalid file specified: " & sFileToCopy )
	Wscript.Quit
ElseIf Not oFSO.FileExists( sServerList ) Then
	Wscript.Echo ("Invalid server list specified: " & sServerList )
	Wscript.Quit
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
			Err.Clear
		Else
			sLog = sLog & vbCrLf & vbCrLf & "CopyFile( '" & sFileToCopy & "', '" & sLocationToCopy & "' ) ERROR - " & sList(X) & " - Unknown Error!"
		End If
	Else
		lSuccess = lSuccess + 1
	End If
Next
 
MsgBox( "Processed: " & lSuccess & vbCrLf & "Failed: " & lErrors)
If lErrors > 0 Then
	Wscript.Echo ("Error Log: " & vbCrLf & sLog )
	Wscript.Quit	
End If 

Open in new window

0
 
johnb6767Commented:
Put the file in an open share.....
Text file atc:\PCNames.txt

PsExec v1.94
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

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....
0
 
johnb6767Commented:
And no scripting needed... Thats the main reason I suggest this. Takes local commands, and makes them available to use remotely....
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now