' Set up some Constants
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
Const ForReading = 1
' Build the date tag for the log file name
sDate = right("00" & cstr(month(date())),2) & right("00" & cstr(day(date())),2) & right("200" & cstr(year(date())),4) & right("00" & cstr(hour(time)),2) & right("00" & cstr(minute(time)),2) & right("00" & cstr(second(time)),2)
' Build the full log file name
sOutFileName = "C:\Temp\reg_scan_log_" & sDate & ".txt"
' set this to the registry key to search
sKeyPath = "SYSTEM\CurrentControlSet\Services"
' Get the FSO moving
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Open the file with containing all of the computers to scan (name or IP address)
Set objTextFile_List = oFSO.OpenTextFile ("C:\Temp\machineList.txt", ForReading)
' Create and open the file for logging
Set objTextFile = oFSO.OpenTextFile(sOutFileName, ForAppending, True)
' Loop through the file containing machine names/IP addresses
Do Until objTextFile_List.AtEndOfStream
sMachine = objTextFile_List.Readline
Set WshShell = CreateObject("WScript.Shell")
bPing = Not CBool(WshShell.run("ping -n 1 " & sMachine, 0, True))
If bPing = True Then
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sMachine & "\root\default:StdRegProv")
' Create an enum of the key values
oReg.EnumValues HKEY_LOCAL_MACHINE, sKeyPath, arrValueNames, arrValueTypes
' duh
ON ERROR RESUME NEXT
' check the array count
If UBound(arrValueNames) > 0 Then
objTextFile.WriteLine(sMachine & ": " & cstr(UBound(arrValueNames)))
End If
' write the error message
If err.number > 0 Then
objTextFile.WriteLine(sMachine & ": " & err.Description)
End If
Else
' Set the appropriate response
objTextFile.WriteLine(sMachine & ": Not on network")
End If
loop