monkeymagic2222
Technical User
Hi,
I am new to VBScripting so don't know if this is possible but I have a script that copies some program files and folders to PC's on the domain by reading in a text file containing PC names. The copy part seems to works fine but I need the script to then run a batch file on the remote machine that registers some of the files that were copied. The batch file itself comes with the software and changes every time we receive an update so I can't hard encode the registry information into the VBScript, which is why I would like to call the batch file.
Heres my code so far, any information would be most appreciated.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\scripts\computers.txt", ForReading)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Do Until objTextFile.AtEndOfStream
strComputers = objTextFile.ReadAll
Loop
objTextFile.Close
arrComputers = Split(strComputers, ",")
For Each strComputer in arrComputers
Set objShell = CreateObject("WScript.Shell")
strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer & ""
Set objExecObject = objShell.Exec(strCommand)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
If Instr(strText, "Reply") > 0 Then
'Loop
objFSO.CopyFile "\\Websense\ASNA_CIS\EB\ebviewindex.ini", "\\" & strComputer & "\c$\Windows\", true
objFSO.CreateFolder "\\" & strComputer & "\c$\syan"
objFSO.CreateFolder "\\" & strComputer & "\c$\syan\asna_cis"
objFSO.CopyFolder "\\websense\ASNA_CIS\*", "\\" & strComputer & "\c$\syan\ASNA_CIS\", true
objFSO.CopyFile "\\websense\ASNA_CIS\*.*", "\\" & strComputer & "\c$\syan\ASNA_CIS\", true
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set oprocess = objWMIService.Get("win32_process")
ret = oprocess.create("cmd.exe /c c:\syan\asna_cis\dll registry\register dll.bat", Null, Null, intProcessID)
' End loop
Else
Wscript.Echo strComputer & " could not be reached."
End If
Loop
Next
I am new to VBScripting so don't know if this is possible but I have a script that copies some program files and folders to PC's on the domain by reading in a text file containing PC names. The copy part seems to works fine but I need the script to then run a batch file on the remote machine that registers some of the files that were copied. The batch file itself comes with the software and changes every time we receive an update so I can't hard encode the registry information into the VBScript, which is why I would like to call the batch file.
Heres my code so far, any information would be most appreciated.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\scripts\computers.txt", ForReading)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Do Until objTextFile.AtEndOfStream
strComputers = objTextFile.ReadAll
Loop
objTextFile.Close
arrComputers = Split(strComputers, ",")
For Each strComputer in arrComputers
Set objShell = CreateObject("WScript.Shell")
strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer & ""
Set objExecObject = objShell.Exec(strCommand)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
If Instr(strText, "Reply") > 0 Then
'Loop
objFSO.CopyFile "\\Websense\ASNA_CIS\EB\ebviewindex.ini", "\\" & strComputer & "\c$\Windows\", true
objFSO.CreateFolder "\\" & strComputer & "\c$\syan"
objFSO.CreateFolder "\\" & strComputer & "\c$\syan\asna_cis"
objFSO.CopyFolder "\\websense\ASNA_CIS\*", "\\" & strComputer & "\c$\syan\ASNA_CIS\", true
objFSO.CopyFile "\\websense\ASNA_CIS\*.*", "\\" & strComputer & "\c$\syan\ASNA_CIS\", true
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set oprocess = objWMIService.Get("win32_process")
ret = oprocess.create("cmd.exe /c c:\syan\asna_cis\dll registry\register dll.bat", Null, Null, intProcessID)
' End loop
Else
Wscript.Echo strComputer & " could not be reached."
End If
Loop
Next