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]: Platform[Next]: RegistryComment
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->Commands->Registry

The "Registry" Command

This command is used to set up registry entries.

If you have the data in "REGEDIT4" registry file format (or can obtain it) you might wish to import this (see the "RegistryImport" command) particularly if an external party is supplying the entries.

Except for values of type "MultiString" the registry command doesn't support appending (or prepending) to existing registry entries, see the "Registry Appending" section for a solution to this.

I recommend that you read the "Resource Life Cycle" section.

If the package installs onto a 64 bit operating system you need to ensure you supply the "64bit" attribute on the controlling "component" command or the value will be put into the "Wow6432Node" node of the registry, for example to "HKLM\Software\Wow6432Node\MyProduct" instead of "HKLM\Software\MyProduct"!

This command takes these parameters:

Main Registry Related Options

Please see the "options for commands" section of the manual.

#define? DEFAULT_REGISTRY_HKEY                       LOCAL_MACHINE
#define? DEFAULT_REGISTRY_TYPE                       STRING
#define? DEFAULT_REGISTRY_ROWKEY_PREFIX              RegKey
#define? DEFAULT_REGISTRY_ACCESS
#define? DEFAULT_REGISTRY_DOCO                       Y          ;;"N" = Don't add to doco (by default)
#define? REGISTRY_COMPONENT_AUTOCREATE_ALLOWED       Y          ;;Y/N
#define? DEFAULT_REGISTRY_OPTIONS4COMPONENT
#define? REGISTRY_COMPONENT_ROWKEY_REXXEXPRESSION    'AutoRC_' || {$RowKeyVar} ;;For autocreated components
#define? REGISTRY_HTMLRPT_HR                          <$SUNDRY_HTMLRPT_HR>
#( '<?NewLine>'
   #define? REGISTRY_STYLES

   .RegistryCmtPlus             {font-size:9pt;}
   .RegistryCmtName             {<$HTMLRPT_STYLE_VALUES_KEY>}
   .RegistryCmtValue            {<$HTMLRPT_STYLE_VALUES_VALUE>}
#)

EXAMPLE - Simple Examples

<$Registry HKEY="CURRENT_USER" Key="Software\DENNIS" Name='STRING1'     Value="1234">              ;;Test string
<$Registry HKEY="CURRENT_USER" Key="Software\DENNIS" Name='CompKeyPath' Value="KP" KeyPath=Y>      ;;Make this registry entry the keypath for the component
<$Registry HKEY="CURRENT_USER" Key="Software\DENNIS" Name='DWORD1'      Value="&H0c" Type="DWORD"> ;;Test dword AND hex literal
<$Property "PORT" VALUE="123">                                                                                                      ;;Set property, could be set by command line or dialog etc
<$Registry HKEY="CURRENT_USER" Key="Software\DENNIS" Name='DWORD2_PROP' Value=^"[PORT]"^     Type="DWORD"     MSIFORMATTED="VALUE"> ;;DWORD comes from property
<$Registry HKEY="CURRENT_USER" Key="Software\DENNIS" NAME="ExpZValue"   VALUE="aaa[~]bbb[~]" TYPE="EXPSTRING" MsiFormatted="VALUE"> ;;Try Multi expand string
<$Registry HKEY="CURRENT_USER" Key="Software\DENNIS" NAME="HexValue"    Value="41,42,43"     TYPE="BINARY">                         ;;Test a binary value

EXAMPLE - Append to existing REG_MULTI_SZ

<$Component "SetupBootExecution" Create="Y" Directory_="INSTALLDIR">
    ;--- Add the script we generated above ----------------------------------
    <$Files "AtBoot.exe" KeyFile="*">

    ;--- Tell Windows to execute the EXE very early in boot (too early for anything fancy) ---
    #(
        <$Registry
                    HKEY="LOCAL_MACHINE"
                     Key="SYSTEM\CurrentControlSet\Control\Session Manager"
                    Name="BootExecute"
                    Type="MultiString"
                   Value=^[~][INSTALLDIR]AtBoot.exe^   ;;Append the EXE name to any existing value
            MsiFormatted="VALUE"
        >
    #)
<$/Component>

See the "Registry Appending" section for an example of a custom action that could be used to append or prepend to other registry types.

EXAMPLE - Use macro to make many similar changes

The following creates a macro which can be used to set your applications registry options (as written will overwrite any existing):

#(
   ;--- Define macro so set application options in registry -----------------
   #define AppOption
   <$Registry
                HKEY="LOCAL_MACHINE"
                 Key="SOFTWARE\MyCompany\MyAppOptions"
                Name=`{$#1}`
               Value=`{$Value}`
             KeyPath="{$KeyPath='N'}"         ;;Optional parm (default = N)
       MsiFormatted="NAME,VALUE"
   >
#)

Example of the new macro being used:

<$Component "RegistryOptions" Create="Y" Directory_="INSTALLDIR">
   ;--- Component Keypath ---------------------------------------------------
   <$AppOption "Installed - By <$ProdInfo.ProductName> <$ProductVersion>" Value=^[Date] [Time]^ KeyPath="Y">

   ;--- Set many options ----------------------------------------------------
   <$AppOption "OptionA" Value=^a^>
   <$AppOption "OptionB" Value=^b^>
                ...
   <$AppOption "OptionZ" Value=^z^>
<$/Component>

The above example shows a number of registry values being created in a manner which is much easier to type and read and if you made a mistake you are much more likely to see it earlier as well.


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]: Platform[Next]: RegistryComment


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday August 13 2017 at 2:39pm
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.