Skip to content

Registry Macros

alexmitev81 edited this page Feb 28, 2018 · 3 revisions

MULTIUSER_RegistryAddInstallInfo

This macro writes proper uninstall information to the Windows registry. Insert it in your code right after the WriteUninstaller instruction.

Usage:

Section "Core Files (required)" SectionCoreFiles
    SectionIn 1 2 3 RO

    ; uninstall previous version

    SetOutPath $INSTDIR
    ; Write uninstaller and registry uninstall info as the first step,
    ; so that the user has the option to run the uninstaller if sth. goes wrong 
    WriteUninstaller "${UNINSTALL_FILENAME}"			
    !insertmacro MULTIUSER_RegistryAddInstallInfo ; add registry keys	
SectionEnd

MULTIUSER_RegistryAddInstallSizeInfo

This macro writes the total size of the installation files to the the Windows registry. Because there is no way to know the total size of all installation files before they get actually copied to the disk, you have to call this macro at the end of the installation. The recommended place is from a hidden section, which is the last section in the list.

Usage:

; should be the last section
Section "-Write Install Size" ; hidden section, write install size as the final step
	!insertmacro MULTIUSER_RegistryAddInstallSizeInfo
SectionEnd

MULTIUSER_RegistryRemoveInstallInfo

This macro removes the uninstall information from the Windows registry. Insert it as the final step in your uninstaller, usually inside a hidden section that executes as the last section.

Usage:

Section "-Uninstall" 
    ; Remove the uninstaller from registry as the very last step - if sth. goes wrong, let the user run it again
    !insertmacro MULTIUSER_RegistryRemoveInstallInfo 
		
    Delete "$INSTDIR\${UNINSTALL_FILENAME}"	
    RMDir "$INSTDIR"  		
SectionEnd