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.
TheNovice001Asked:
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
		Else
			objLogFile.WriteLine strCurrentPC & " - Computer offline"
		End If
	Next
Loop

Open in new window

0
 
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!
0
 
merowingerCommented:
your welcome ;)
thanks for the refunds
0
 
dmq127Commented:
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?

Thanks
0
 
merowingerCommented:
I think best way is to use VBScript Special folders in this case
http://msdn.microsoft.com/en-us/library/0ea7b5xe(VS.85).aspx

e.g.
strAllUsersDesktop = WshShell.SpecialFolders("AllUsersDesktop")

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

e.g.
strAllUsersProfile = WshShell.ExpandEnvironmentStrings("ALLUSERSPROFILE")


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

From novice to tech pro — start learning today.