Preciso de um Script que copie um determinado arquivo do um Servidor \\Servidor\teste.txt e coloque em cada maquina de minha rede na pasta \\maquina\C$\Documents and Settings\All Users\Menu Iniciar\Programas\Inicializar.
Se Possivel me lista as Maquina que foram copiadas com sucesso como um LOG, e a Data e hora do processo.
Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns Dim strArq, strOrig, strDest Dim intConstants, intTimeout, strTitle, intCount, blnLog Dim strUserName, strComputerName, strIP, strShare, strLogFile
' NOME DO ARQUIVO strArq = "opcao8.jpg" ' PASTA ORIGEM strOrig = "\\server\compartilhamento\" ' PASTA DESTINO strDest = "c:\" ' PASTA DO ARQUIVO DE LOG strShare = "c:\" ' NOME DO ARQUIVO DE LOG strLogFile = "teste.txt" ' TIMEOUT PARA TENTAR EXECUTAR intTimeout = 20
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objNetwork = CreateObject("Wscript.Network") Set objShell = CreateObject("Wscript.Shell")
' Log date/time, user name, computer name, and IP address. If (objFSO.FolderExists(strShare) = True) Then On Error Resume Next Set objLogFile = objFSO.OpenTextFile(strShare & "\" _ & strLogFile, 8, True, 0) If (Err.Number = 0) Then intCount = 1 blnLog = False Do Until intCount = 3 objFSO.CopyFile strOrig & strArq , strDest & strArq , true objLogFile.WriteLine "Copia de Arquivo ; " & Now & " ; " _ & strComputerName & " ; " & strUserName If (Err.Number = 0) Then intCount = 3 blnLog = True Else Err.Clear intCount = intCount + 1 If (Wscript.Version > 5) Then Wscript.Sleep 200 End If End If Loop On Error GoTo 0 If (blnLog = False) Then strTitle = "Erro" strText = "Não pode gravar o log." strText = strText & vbCrlf _ & "Outro processo pode estar com o arquivo aberto." intConstants = vbOKOnly + vbExclamation intAns = objShell.Popup(strText, intTimeout, strTitle,intConstants) End If objLogFile.Close Else On Error GoTo 0 End If Set objLogFile = Nothing End If
Set objFSO = Nothing Set objNetwork = Nothing Set objShell = Nothing