Read directories from registry in VB

Pegun

Golden Member
Jan 18, 2004
1,334
0
71
Hey all, I'm using a script that reads everything from the hklm\software\oracle to find the directories that are associated with oracle. The problem i have with this is I'm trying to find the home directory and not the installed directory, which is what is echoed. Anyone see any way of helping me out?

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

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

strKeyPath = "SOFTWARE\Oracle"
objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes

Dim temp
For i = 0 to UBound(arrValueNames)
strValueName = arrValueNames(i)
if strValueName = "ORACLE_HOME" then
temp = strValue
End if
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Wscript.Echo arrValueNames(i) & " -- " & strValue
Next

WScript.Echo("temp = " & temp)
 

KLin

Lifer
Feb 29, 2000
30,449
752
126
You need to go down another level for strKeyPath. There should be something like a HOME0, HOME1, etc key under oracle. That's where the ORACLE_HOME value is stored. I added HOME0 to strKeyPath and was able to get it to work.


EDIT: If there's more than one installation of Oracle though, it's going to add another key like HOME1, so you may need to create another loop for like 5 instances of home or however you want to do it.