TryMeDualPurposePackage-SupportsWinXP.MM |
This is one of the MAKEMSI samples which build a new MSI/MSM. This MSI makes use of these "TryMe.MM" files:
This demonstrates dual-purpose package (single package authoring).
;---------------------------------------------------------------------------- ; MODULE NAME: TryMeDualPurposePackage-SupportsWinXP.MM ; ; $Author: USER "Dennis" $ ; $Revision: 1.0 $ ; $Date: 28 Feb 2016 15:41:28 $ ; $Logfile: D:/DBAREIS/Projects.PVCS/Win32/MakeMsi/TryMeDualPurposePackage-SupportsWinXP.MM.pvcs $ ; ; DESCRIPTION ; ~~~~~~~~~~~ ; Shows one way of creating a dual purpose package (DPP) which is also ; referred to as Single Package Autrhoring. ; ; If we only cared about supporting WIN7+ (Windows Installer 5.0+) then this ; would be easier as then you'd be able to use these properties: ; * MSIINSTALLPERUSER ; * ProgramFilesFolder ; * CommonFilesFolder ; * ProgramFiles64Folder ; * CommonFiles64Folder ; ; This msi supports per-machine & per-user installation in Windows 7+ as well ; as WINXP. ;---------------------------------------------------------------------------- ;----[Step1.4MakemsiManaual]---- ;---------------------------------------------------------------------------- ;--- PER-USER Installation [STEP 1, BEFORE #INCLUDE MAKEMSI) ---------------- ;---------------------------------------------------------------------------- ;#define? SELFREG_ORDERED_CA_TYPE_PU &H0C62 ;;Ignore the return code as not all products support per-user install ("LogParser.dll" for example) #define COMPANY_HTMLRPT_DOCO_INSTALL_DIR_KEY INSTALLDIR #define COMPANY_HTMLRPT_DOCO_INSTALL_DIR [INSTALLDIR] ;;peruser location / Overkill as now have defined: COMPANY_HTMLRPT_DOCO_INSTALL_DIR_KEY #define COMPANY_HTMLRPT_NAME_LONG <$ProdInfo.ProductName> (version <$ProductVersion>).hta #define COMPANY_ALLUSERS_CREATE_PROPERTY N ;;ALLUSERS need to not exist to be per-user [See variation below] ;----[Step1.4MakemsiManaual]---- ;---------------------------------------------------------------------------- ;--- Include MAKEMSI support (with my customisations and MSI branding) ------ ;---------------------------------------------------------------------------- #define VER_FILENAME.VER TryMe.Ver ;;I only want one VER file for all samples! (this line not actually required in "tryme.mm") #include "ME.MMH" ;----[Step2.4MakemsiManaual]---- ;------------------------------------------------------------------------------ ;--- This sets things up for per-user/machine in WIN7 and per-user in WinXP --- ;------------------------------------------------------------------------------ <$Property "MSIINSTALLPERUSER" Value="1"> ;;Property is ignored prior to WIN7, on WIN7+ will update "ALLUSERS" value we assign below to peruser or permachine <$Property "ALLUSERS" Value="2"> ;;PerUser in WInXP, in WIN7+ this value will be modifiued because of "MSIINSTALLPERUSER" above ;---------------------------------------------------------------------------- ;--- In WINXP, ALLUSERS=2 (per-user), Can this user install per-machine? ---- ;---------------------------------------------------------------------------- #define USER_CAN_INSTALL_PER_MACHINE_AND_NOT_WIN7_PLUS (VersionMsi < "5.00") and Privileged ;;Per-user default already set, override to install per-machine if user has permissions <$PropertyCa "ALLUSERS" Value="" Condition=^<$USER_CAN_INSTALL_PER_MACHINE_AND_NOT_WIN7_PLUS>^ Type=^Immediate^ Seq="LaunchConditions-" SeqTable="InstallUISequence InstallExecuteSequence"> ;------------------------------------------------------------------------------- ;--- Now depending on whether per-machine or not Need to modify Install dir --- ;------------------------------------------------------------------------------- <$Directory KEY="INSTALL_HERE_DIR" PARENT="AppDataFolder" DIR="." ASIS="Y" CHANGE="."> ;;Good for per-user <$PropertyCa "INSTALL_HERE_DIR" Value="[CommonAppDataFolder]" Condition=^(<$CONDITION_PER_MACHINE>) and <$CONDITION_INSTALL_ONLY>^ Seq=^-CostFinalize^ SeqTable="InstallUISequence InstallExecuteSequence"> ;---------------------------------------------------------------------------- ;--- Need to ignore some validation messages -------------------------------- ;---------------------------------------------------------------------------- <$MsiValFilter RE="Y" "Component '.*' has both per-user data and a keypath that can be either per-user or per-machine"> <$MsiValFilter RE="Y" "The file '.*' will be installed to the per user directory '.*' that doesn't vary based on ALLUSERS value"> <$MsiValFilter "The directory INSTALL_HERE_DIR is in the user profile but is not listed in the RemoveFile table" Comment=^Nothing actually created^> ;----[Step2.4MakemsiManaual]---- ;---------------------------------------------------------------------------- ;--- Define the installation Directory -------------------------------------- ;---------------------------------------------------------------------------- <$Component "INSTALLDIR" Create="Y" Directory_="<$AnyDir>" CU="?"> <$DirectoryTree Key="INSTALLDIR" Dir="[INSTALL_HERE_DIR]\<$ProdInfo.ProductName>" MAKE="Y" REMOVE="Y" CHANGE="\"> ;;All Users Application data, redirected to "C:\ProgramData" on WIN7 ("all users" profile on WINXP) <$/Component> ;---------------------------------------------------------------------------- ;--- Create a File to dump some properties ---------------------------------- ;---------------------------------------------------------------------------- #define SCRIPT_VBS_BASENAME SimpleScriptToDumpProperties.VBS #define SCRIPT_VBS_IN_LOGDIR <$MAKEMSI_VBSCRIPT_DIR>\<$SCRIPT_VBS_BASENAME> <$FileMake "<$SCRIPT_VBS_IN_LOGDIR>"> <?SyntaxCheck> MsgBox wscript.arguments(0), vbInformation, "<?InputComponent $$FilePart:name> version <$ProductVersion>" <$/FileMake> ;---------------------------------------------------------------------------- ;--- Install the file ------------------------------------------------------- ;---------------------------------------------------------------------------- <$Component "GeneralFiles" Create="Y" Directory_="INSTALLDIR" CU="?"> <$File Source="<$SCRIPT_VBS_IN_LOGDIR>" Comment=^Simple test script to be invoked by the shortcut.^> <$/Component> ;---------------------------------------------------------------------------- ;--- Install the shortcut --------------------------------------------------- ;---------------------------------------------------------------------------- <$Component "Shortcut" Create="Y" Directory_="INSTALLDIR" CU="?"> #( <$Shortcut Dir="ProgramMenuFolder" Target="[INSTALLDIR]<$SCRIPT_VBS_BASENAME>" Arguments=^"This product installed to '[INSTALLDIR]', it created shortcuts at '[ProgramMenuFolder]' and ALLUSERS was '[ALLUSERS]' (=1 means per-machine)."^ Title="<?InputComponent $$FilePart:name> Shortcut" > #) ; <$MsiValFilter "has both per-user and per-machine data with an HKCU Registry KeyPath" Comment=^Bad luck :-)^> <$/Component>