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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.