script to read registry subkeys and values

  • Follow


Hi all, hoping someone can help me here...

I have the following two scripts, one reads the values of a key and one 
reads the subkeys of the key:

dim fs, a, x, y

Const HKEY_LOCAL_MACHINE = &H80000002

Set fs = CreateObject("Scripting.FileSystemObject")

Set a = fs.CreateTextFile("C:\apps\Output.xls", True)


strComputer = "."

Set objRegistry = GetObject("winmgmts:\\" & strComputer & 
"\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Landmark Graphics Corporation\EDT\5000.1"

objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, 
arrValueTypes

For i = 0 to Ubound(arrValueNames)

  strValueName = arrValueNames(i)

  objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, 
strValue  

  x = x & strValueName & " -- " & strValue & vbCrLf

Next


a.WriteLine(x)

 
strComputer = "."

strKeyPath = "SOFTWARE\Landmark Graphics Corporation\EDT\5000.1"  

Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & 
strComputer & "\root\default:StdRegProv") 

EchoSubkeys HKEY_LOCAL_MACHINE, strKeypath  


Sub EchoSubkeys(HKEY_LOCAL_MACHINE, strKeyPath)   

objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys 

If IsArray(arrSubkeys) Then     

  For Each strSubkey In arrSubkeys       

    EchoSubkeys HKLM, strKeyPath & "\" & strSubkey     

  Next   

End If  

y = y & strKeyPath & vbCrLf 

End Sub

a.WriteLine(y)

a.close
Now I would like to be able to output the subkeys of the key, and the 
subkeys of the subkeys....AND on top of that output the values of all the 
subkeys, I know it is probably quite easy but just can't get it to work.

Any help much appreciated

0
Reply Utf 10/7/2010 11:21:03 AM


0 Replies
494 Views

(page loaded in 0.357 seconds)


Reply: