Thanks in advance...
Searching for a registry KEY (not value)
Posted 15 February 2001 - 20:00
Posted 15 February 2001 - 23:49
Just add a custom action that calls this script and sets a property to TRUE/FALSE
export prototype MyKeyExists(HWND);
function MyKeyExists(hMsi)
STRINsRegKey;
LONGlResult;
begin
sRegKey="Software\\Widgets\\MyWidget";
RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
if (RegDBKeyExist(sRegKey) = 1) then
lResult=MsiSetProperty(hMsi,"REGKEYEXISTS",TRUE);
else
lResult=MsiSetProperty(hMsi,"REGKEYEXISTS",FALSE);
endif;
return ERROR_SUCCESS;
end;
Remember to define REGKEYEXISTS in the properties editor of the project.
Posted 16 February 2001 - 02:09
The following VB code snippet illustrates the process:
On Error Resume Next
Dim oObject As IWshShell
Dim sString As String
Set oObject = New IWshShell_Class
sString = oObject.RegRead("HKLM\SOFTWARE\SHS\Setup\Foobar\")
If Err.Number <> 0 Then MsgBox "error " & Str(Err.Number): End
Posted 16 February 2001 - 07:16
Posted 28 February 2001 - 22:10
Well, not that I've seen every registry in the world, but I've never seen a key that didn't have a Default entry.
I'll bet looking for that would work.
Rob
Posted 01 March 2001 - 01:49
The action of the AppSearch action is to set the Property indicated by the AppSearch Table to the value of the Signature. If the Default Value is chosen, it is also often blank, and the Property Table does not allow blanks in the setting of a property name ... so I suspect the action would fail, even if the key existed.
I think the only way to guarantee the significance of the response would be to use a script object. However, I have not tried using a dummy file/folder and looking for a key that is guaranteed to have some value associated with it, if it exists.
Posted 01 March 2001 - 07:42
thanks for your ideas. However I can search for registry entries that are not related to files in the AppSearch action. To do this I specify msidbLocatorTypeRawValue in the Type column. This works fine.
If the entry doesn't exist or is empty, the specified property will not exist (it's not specified in the property table) or will resolve to an empty string.
The problems are: Often a default value does not exist, even if the key exists. And if the default value exists, it may be empty, which I cannot destinguish (undefined property resolves to empty string). So a custom action (script or DLL) would be required to check for the existance of a key.
I worked around this limitation by looking for a value in the key that must not be empty.
Posted 23 July 2001 - 21:42
object.RegistryValue(root, key, value)
If you do not specify a value it will return a boolean designating whether the key exists.
-maria