Hy

First sorry for my bad ingles (Iâ??m Portuguese)

Y have a big problem and y need so solve son y cant

1º Y have a file (xxxxx.ini) in my server, and y need copy the file to the
computers in my LAN
2º This file need copy to the (System Root) of the computers
3º I have a file calls computers.txt where y put all de computers in my land
4º If the file donâ??t enter in the computer, I need to receive an e-mail

So, itâ??s possible to have a script to calls the computers.txt and copy de
file to the computers, and receive a e-mail end a error occurs.

Thanks for your help,

Re: Copy file from one computer to hall the computers in my Lan by Ginolard

Ginolard
Fri May 27 08:56:49 CDT 2005

Try this. It will read in the list of machines, test if the machine is
online (if not, write an error to the log) and then try to copy the
file and log an error if it fails for any reason

On Error Resume Next
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

sPath = "path to your file
sdest="destination"

Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set Logfile=objFSO.OpenTextFile("c:\temp\CopyFile.log",ForWriting,True)

fileIn=objFSO.OpenTextFile("path to file containing
machines",ForReading).ReadAll

strComputer = Split(fileIn,VbCrLf)
For i = 0 to UBound(strComputer)

If IsConnectible(strComputer(i)) Then
Call CopyFile(strComputer(i))
Else Logfile.Writeline strComputer(i) & " Not online" & VbCrLf
End If
Next


Private Function CopyFile()
Result=objFso.CopyFile (spath,"\\" & strcomputer(i) & sdest)

If Err.Number >0 Then
Logfile.Writeline "There was an error copying the file to " &
strComputer(i) & VbCrLf
End If

End Function


Function IsConnectible(PCName)
IsConnectible=False

Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '" &
PCName & "'")

For Each objStatus in objPing
If Not IsNull (objStatus.ReplySize) Then
IsConnectible = True
End If
Next

End Function