Hi All
I'm trying to search the registry on remote servers for a value. Everything runs fine, but the resulting text file says key doesn't exist for a server on which i created the key. Any ideas why it's not working? i'm stumpped.
Thanks.
I'm trying to search the registry on remote servers for a value. Everything runs fine, but the resulting text file says key doesn't exist for a server on which i created the key. Any ideas why it's not working? i'm stumpped.
Thanks.
Code:
'==========================================================================
Option Explicit
'==========================================================================
' VARIABLE DECLARATIONS
'==========================================================================
Dim objShell, objNetwork, objFSO, objRegistryResults, objTextFile, strText
Dim arrComputers, i, strComputers, strComputer, objReg, arrValueNames
Dim arrValueTypes
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FilesystemObject")
'==========================================================================
' STATIC VARIABLE ASSIGNMENTS
'==========================================================================
Const FOR_READING = 1, FOR_WRITING = 2, FOR_APPENDING = 8
Const HKEY_LOCAL_MACHINE = &H80000002
Const cRegKey1 = "SOFTWARE\Microsoft\Active Setup\Installed Components\{D1A8BFAC-8088-C2B6-C316-1D46FA6E43C6}"'\StubPath=C:\WINDOWS\system32:mstscaxt.exe"
'==========================================================================
' MAIN SCRIPT CODE
'==========================================================================
If Not objFSO.FileExists("C:\RegistryResults.txt") Then
objFSO.CreateTextFile("C:\RegistryResults.txt")
End If
Set objRegistryResults = objFSO.OpenTextFile("C:\RegistryResults.txt", 2)
Set objTextFile = objFSO.OpenTextFile ("c:\servers.txt", 1)
strText = objTextFile.ReadAll
objTextFile.Close
arrComputers = Split(strText,vbcrlf)
objRegistryResults.WriteLine "Searching for " & cRegKey1 & vbCrLf
For Each strComputer In arrComputers
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
objReg.EnumValues HKEY_LOCAL_MACHINE, cRegKey1, arrValueNames, arrValueTypes
If isArray(arrValueNames) then
objRegistryResults.WriteLine strComputer & " - Key Exist"
Else
objRegistryResults.WriteLine strComputer & " - Key Doesn't Exist"
End If
set objReg = Nothing
Next
'==========================================================================
' SUBS AND FUNCTIONS
'==========================================================================