Answer
In order to allow the user to choose the installation type at run-time add the InstallType dialog to the project (Dialog Editor Page). In Install Parameters Page set the install type to: Per-machine if user is administrator, per-user otherwise.
In order to work properly the “InstallType” dialog
should be added before any other dialogs that allow the user to
customize the installation.
The Application Folder and Application Shortcut Folder and all their sub-folders will be automatically redirected to per-user/per-machine locations if certain configuration rules are met:
- The Application Folder default value (configurable in the Install Parameters Page) must contain reference to either [ProgramFilesFolder], [ProgramFiles64Folder], [CommonFilesFolder], [CommonFiles64Folder] predefined windows installer folders.
- The Application Shortcut Folder default value (configurable in the Install Parameters Page) must contain reference to [ProgramMenuFolder].
Using this dialog also provide per-user/per machine upgrade process. This means that when the installation type is changed the applications to be upgraded are searched again in concordance with the new installation context.
When running on Windows Installer 5.0 or higher the
“InstallType” dialog will automatically set the
MSIINSTALLPERUSER property used in single package authoring.