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:
Note that "CLASSES_ROOT" is a mixture made up of "software\classes" registry information from current user and local machine registry hives.
The default for this parameter can be set via the DEFAULT_REGISTRY_HKEY macro. The initial value for this is "LOCAL_MACHINE".
If the value contains msi formatting then you will need to use the "MsiFormatted" parameter (by default this command will escape "[" and other similar formatting characters).
If using "[~]" (update rather than replacing registry values) you should also see these bugs:
If your value begins with "[~]" ("[~]a[~]b[~]c") then your value will be appended to any existing registry value strings.
If your value ends with "[~]" ("a[~]b[~]c[~]") then your value will be prepended to any existing registry value strings.
If your value begins & ends with "[~]" or it appears at neither end then your value will replace any existing registry value strings. If your value doesn't contain any "[~]" sequences at all then MAKEMSI will add this to the start and end of the string for you (as Windows Installer requires the value contain at least 1 occurance). Note that the value will be processed as if you'd specified "VALUE" on the "MsiFormatted" parameter as the "value" will always contain msi formatting (at least 1 "[~]").
The "Value" parameter will be left as is (raw) which assumes that you have supplied it with correct MSI formatting as well as the appropriate "prefix" (such as "#" for dword) as per the rules documented for the "Value" column of the "Registry" table.
The default for this parameter can be set via the DEFAULT_REGISTRY_TYPE macro. The initial value for this is "STRING".
If you are not within a component or you pass "" for this parameter then a component will be made for this registry entry. If required you can pass Component parameters in the "OPTIONS4COMPONENT" parameter.
The default for this parameter can be set via the DEFAULT_REGISTRY_OPTIONS4COMPONENT macro. The initial value for this is "".
If you have supplied MSI formatted values then you need to tell MAKEMSI this so that it will leave the value you supplied alone, otherwise it will "fix" (escape) the values. If you wish to refer to any MSI properties, directories or file keys etc you will need to use MSI formatting and handle any other characters (such as "[") yourself.
By default this parameter has a value of "", otherwise you can supply a space or comma separated list of 1 or more of the following items:
The default for this parameter can be set via the DEFAULT_REGISTRY_DOCO macro. The initial value for this is "Y".
The default is "".
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 MmRegistry #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.