Simple Script to Copy Files to Multiple Computers.

I'm looking for an easy to use script that will copy files from one computer (c:\source files\) to a specific folder (\\computername\ c:\programs files\destination\) of multiple computers. If it can create a log file that shows which copies were successful or failed that would be great!

The program will run from the source computer.
Who is Participating?
merowingerConnect With a Mentor Commented:
This following vbscript (*.vbs) will read computernames ot ouf the Computers.txt, check connectivity to them and then copy the files.
Everything is written into a logfile
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
set objShell = CreateObject("Wscript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
set objLogFile = objFSO.CreateTextFile("D:\Copy.log")
set objComputers = objFSO.OpenTextFile("D:\Computers.txt")
strSource = "D:\source"
strTarget = "c$\Program Files\Destination"

Do while not objComputers.AtEndOfStream
	strCurrentPC = objComputers.ReadLine

	'First check connection
	Set colPing = objWMIService.ExecQuery("Select * from Win32_PingStatus Where Address = '" &strCurrentPC &"'")
	For each objPing in colPing
		If objPing.StatusCode = 0 Then
			objLogFile.WriteLine strCurrentPC & " - Computer online - Trying to copy"
			On Error Resume Next
			return=objShell.Run ("xcopy " & strSource &"\*.* " &chr(34) &"\\" &strCurrentPC &"\" &strTarget &"\*.*" &chr(34) &" /F /E",0,true)
			On Error Goto 0
			objLogFile.WriteLine strCurrentPC & " - Copy Result:" &return
			objLogFile.WriteLine strCurrentPC & " - Computer offline"
		End If

Open in new window

TheNovice001Author Commented:
I didn't think anyone would get back to me until later this morning.  I mean afterall my question was asked at 2:00 AM.  This is an outstanding service! Thank you very much for your prompt reply to my question!
your welcome ;)
thanks for the refunds
I am trying to get this script to copy files or a folder to every existing user's profile "Application Data" folder, but am not having any luck.  I can get it to copy anywhere but.  I'd like to get it to copy to default users and all users also.  What string or wildcard command would be needed for this?

I think best way is to use VBScript Special folders in this case

strAllUsersDesktop = WshShell.SpecialFolders("AllUsersDesktop")

You can also try to resolve environmental variables like %ALLUSERSPROFILE%,  %USERPROFILE% or %APPDATA%

strAllUsersProfile = WshShell.ExpandEnvironmentStrings("ALLUSERSPROFILE")

It's important that this script will be executed with local Administrator permissons to copy into default or allusers profile
All Courses

From novice to tech pro — start learning today.