The "RegistryRead" Command |
This command is used to "read" the value of a registry entry. The retrieved value is placed into a property specified by you.
This command takes these parameters:
If not specified then the existance of the property will be validated (the install will fail if it does not exist).
This value can be "" to indicate that no validation should take place (the property is not set to null).
If you have not used the "Default" parameter and the MSI needs to display an error message it will use a default message unless you specify what it should say with this parameter. Note that the message can contain MSI formatting or "CRLF".
The "Validate" parameter controls whether or not we will fail (displaying this message) if the file isn't found.
Due to Windows Installer restrictions you would also need to turn off validation if the existing registry values can contain empty strings (either that or prevent this if you control them by creating an empty "code").
The default for this parameter can be set via the DEFAULT_REGISTRYREAD_64BIT macro. This is initially "N".
The default signature is the property name so if you make this meaningful then you probably don't need to use this parameter (except in the case where you might be populating the same property from two or more sources).
Format of the Results |
The read is done via Windows Installer "RegLocator" and "AppSearch" table entries.
The documentation for these says that the returned result is prefixed with:
Registry type | Prefix added by Installer |
---|---|
REG_SZ | Normally no prefix, however if the first character of the registry value is a "#", the installer escapes the character by prefixing a another "#". |
DWORD | "#" optionally followed by '+' or '-' |
REG_EXPAND_SZ | "#%" |
REG_MULTI_SZ | Null. The installer sets the property to a value beginning with a null and ending with a null. |
REG_BINARY | "#x", also the installer converts and saves each hexadecimal digit (nibble) as an ASCII character prefixed by "#x". |
Obviously string values (which can bnever begin with "#") are the easiest to use, for other types (except for simple comparisons) you will probably need the help of a custom action to handle the value.
EXAMPLES |
This shows how you can work out if you are on a workstation or server, the result is placed into the property "WINDOWS_PRODUCT_TYPE" (as there is no defined "default" value the install will abort if the value doesn't exist):
;--- Read the value ------------------------ #( <$RegistryRead Property="WINDOWS_PRODUCT_TYPE" HKEY="LOCAL_MACHINE" Key="SYSTEM\CurrentControlSet\Control\ProductOptions" Name="ProductType" > #) ;--- Display the result in a message box --- <$VbsCa Binary="DisplayProperty.vbs"> <$VbsCaEntry "Install"> PropertyBox("<$VbsCaEntryName>") <$/VbsCaEntry> <$VbsCaEntry "UnInstall"> PropertyBox("<$VbsCaEntryName>") <$/VbsCaEntry> '======================= sub PropertyBox(When) '======================= ;--- Get the value of the MSI property --------------- dim PropertiesValue : PropertiesValue = VbsCaPropertyGet("WINDOWS_PRODUCT_TYPE", "", "") ;--- Display when we were invoked + property value --- CaMsgBox "I", "The " & When & "() routine was invoked." & vbCRLF & vbCRLF & "Property = " & PropertiesValue end sub <$/VbsCa> <$VbsCaSetup Binary="DisplayProperty.vbs" Entry="Install" Seq="AppSearch-" Type="immediate" SeqTable="InstallUISequence" CONDITION=^<$VBSCA_CONDITION_INSTALL_ONLY>^>