cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bbarton11
Level 5

How to get a registry key (not string value)

Can someone tell me how I can get a key value from the registry? I've seen examples of how to get a registry value from a string but I am looking for a key value.

For example, I am trying to determine if a machine has .NET Framework 4.0 installed on it. The key I'm trying to look at is [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]. I'd like to retrieve v4.0.30319 into a string and give a message if that key is not available.

Thanks!
Labels (1)
0 Kudos
(11) Replies
RobertDickau
Flexera Alumni

There's RegDBKeyExist if you know the exact key beforehand and just want to make sure it exists, or RegDBQueryKey if you want a list of subkeys.
0 Kudos
bbarton11
Level 5

Thanks, Robert. If I do a query and get a list of keys, is there a way to find a particular key then do a substr() on it? For example, if I'm looking for version numbers in HKLM\SOFTWARE\Microsoft\.NETFramework, can I get v.4.0, v.3.0, etc?

The exists function works for me for now because I know what I'm looking for, though.
0 Kudos
RobertDickau
Flexera Alumni

There's ListFindString, if you know the complete string to find. (In that case you could just use -KeyExist, though.) Otherwise, you'll probably have to loop over the list items (ListGetFirst/NextString), see if what you want is in a particular item, and then use StrSub to get the range of characters you need.

Robert
0 Kudos
Christopher_Pai
Level 16

It is impossible to read a "key" into a string because a key doesn't have data. Only Values have data.

Hive | Key | SubKey | Value [DATA]
0 Kudos
Roman1
Level 9

Please look at RegDBQueryKey.
This function allow you to list all SubKeys.
0 Kudos
bbarton11
Level 5

I'm basically looking to find out if the "Version" for these keys are 10.50.x.x:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\Setup
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Setup


Both those keys have a string, "Version", I'm looking for but the keyname after MSRS10_50. will obviously be different. Is there I was I can get that info to determine if SQL Server 10.50.x.x is installed?

Thanks!
0 Kudos
Christopher_Pai
Level 16

I believe that registry key implies that an instance of SQL Server named MSSQLSERVER is installed. Do you want to be that tightly coupled?

Personally I leverage the built-in SQL handling of InstallShield. I use the SQLLogin dialog and SQL Connections features to have InstallShield do a test connection to the server and verify that it meets my version requirements. Would this not meet your needs?
0 Kudos
bbarton11
Level 5

Christopher Painter wrote:
I believe that registry key implies that an instance of SQL Server named MSSQLSERVER is installed. Do you want to be that tightly coupled?

Personally I leverage the built-in SQL handling of InstallShield. I use the SQLLogin dialog and SQL Connections features to have InstallShield do a test connection to the server and verify that it meets my version requirements. Would this not meet your needs?


No, this wouldn't be ideal for our needs (although it's a great idea!). We basically want the installer to check to see if certain prereqs are installed. If not, produce a message saying what's missing and abort.
0 Kudos
bbarton11
Level 5

I'm using RegDBQueryKey to make a list of the keys in HKLM\Software\Microsoft\Microsoft SQL Server. I know I can use ListFindString to find a line of data in the queried list, but can I have it search for just part of a value? For example look for MSSQL10_50 instead of MSSQL10_50.MSSQLServer?

I think the ListFindKeyValueString function might be the answer but I can't find any examples on how to use it.

Thanks!
0 Kudos
RobertDickau
Flexera Alumni

I'm not aware of a single function to do that. You might have to loop over the items and see if the string you want is there as mentioned in [post=486463]#4[/post].
0 Kudos
munsingh
Level 6

If your requirement is to check whether .net 4 is present, doesn't the existing Predefined search satisfy your need? There is a predefined search for searching .net framework 4.0 full package and the client package.
0 Kudos