with the following vbs, it reads a input file that has a list of computer names. from that it lets me know the local admins for each pc.
problem is that if a pc is hung yet pingable the script just sits at that hung pc waiting for the info. Is there a way to add something to this script to make it continue if no response from the pc within 60seconds?
thank you..
here is the script i have:
'Option Explicit
Const LogFile = "C:\temp\list.log"
Const resultFile = "C:\temp\pc_list.csv"
Const inputFile = "C:\temp\pc_list.txt"
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim shl
Set shl = WScript.CreateObject("WScript.Shell")
Dim fil
Set fil = fso.OpenTextFile(inputFile)
Dim results
Set results = fso.CreateTextFile(resultFile, True)
WriteToLog "Beginning Pass of " & inputFile & " at " & Now()
'WScript.Echo "Beginning Pass of " & inputFile & " at " & Now()
On Error Resume Next
Dim grp
Dim line
Dim exec
Dim pingResults
Dim member
While Not fil.AtEndOfStream
line = fil.ReadLine
Set exec = shl.Exec("ping -n 1 -w 1000 " & line)
pingResults = LCase(exec.StdOut.ReadAll)
If InStr(pingResults, "reply from") Then
WriteToLog line & " responded to ping"
'WScript.Echo line & " responded to ping"
On Error Resume Next
results.WriteLine "=== PCName ===" & ",=== Admin ===,"
Set grp = GetObject("WinNT://" & line & "/Administrators")
'WScript.Echo line & ", Administrators"
For Each member In grp.Members
'WScript.Echo "Administrators: " & member.Name
WriteToLog line & ":" & member.Name
results.WriteLine line & "," & member.Name
Next
Else
WriteToLog line & " did not respond to ping"
'WScript.Echo line & " did not respond to ping"
End If
Wend
results.Close
Sub WriteToLog(LogData)
On Error Resume Next
Dim fil
'8 = ForAppending
Set fil = fso.OpenTextFile(LogFile, 8, True)
fil.WriteLine(LogData)
fil.Close
Set fil = Nothing
End Sub