MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: RegistryImport[Next]: RemoveFile
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->Commands->RegistryRead

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:

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>^>


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: RegistryImport[Next]: RemoveFile


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.