Hi all,
I'm trying to run the below script on multiple machines over the network. It should run an auditing program on each machine that is in computers.txt list. The text file has 1 PC name per line. It works PERFECTLY when ran on a single PC, even a remopte one, however I just cannot get it to read from the txt file and run on multiple PC's. Any help or pointers as to where exactly I'm going wrong would be great as I'm fairly new to VB and this problem has been getting to me for over a week now. I'd like to perform the task this way as it'll save me having to remotely connect to each PC/go to each PC/kick a user off whilst I do this.
Many thanks, Steven
I'm trying to run the below script on multiple machines over the network. It should run an auditing program on each machine that is in computers.txt list. The text file has 1 PC name per line. It works PERFECTLY when ran on a single PC, even a remopte one, however I just cannot get it to read from the txt file and run on multiple PC's. Any help or pointers as to where exactly I'm going wrong would be great as I'm fairly new to VB and this problem has been getting to me for over a week now. I'd like to perform the task this way as it'll save me having to remotely connect to each PC/go to each PC/kick a user off whilst I do this.
Many thanks, Steven
Code:
On Error Resume Next
Set objGetComputerList = CreateObject("Scripting.FileSystemObject")
Set fsoReadComputerList = objGetComputerList.OpenTextFile("computers.txt", 1, TristateFalse)
aryComputers = Split(fsoReadComputerList.ReadAll, vbCrLf)
fsoReadComputerList.Close
For Each strComputer In aryTasks
'*******************************************
'Single PC
'strComputer = "."
Const INTERVAL = "n"
Const MINUTES = 1
strCommand = "C:\WinAudit.exe /r=gso"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objScheduledJob = objWMIService.Get("Win32_ScheduledJob")
Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")
objSWbemDateTime.SetVarDate(DateAdd(INTERVAL, MINUTES, Now()))
errReturn = objScheduledJob.Create(strCommand, objSWbemDateTime.Value, False, 0, 0, True, intJobID)
If errReturn = 0 Then
Wscript.Echo "WinAudit was started with a process ID: " & intJobID
Else
Wscript.Echo "WinAudit could not be started due to error: " & errReturn
End If
'*******************************************
Next