Hi,
The run as admin option is enabled by specifying the execution level in the manifest file.
This manifest file is included only in executable files.
Therefore, you cannot include it into an MSI. The MSI is just a database holding the install information, msiexec.exe (Windows Installer) is actually the EXE that performs the installation
(of course, by following the contents of the MSI it loaded). But you cannot modify MSIEXEC because this is a system resource. Also there is no command line parameter to pass that will make the installer elevate automatically (and show the UAC prompt).
There is one thing that you can do. That is to build a simple EXE in Visual Studio that will launch your MSI. To your own EXE you can easily set the execution level in the manifest to
requireAdministrator. This EXE must do only one thing, i.e. to call msiexec.exe with the proper command line that will install your MSI. At this point msiexec will inherit the execution
credentials from the parent process and will run as admin (just as it happens if you enable the option Run as Admin from Install Parameters page).
It is very important that your EXE waits for the entire installation to finish before exiting itself, otherwise it will trick the main installer into thinking the prerequisite finished installing
and it will try to continue the installation of other prerequisites or of the main package, which can result in errors, because
Windows Installer does not allow multiple MSI installations to run at the same time.
Also, when you define the prerequisite, the EXE must be selected as the target file (main installer), and the MSI file should be added under the
Files section, as an additional resource. So the EXE will find it in the same path and thus be able to get the path of the MSI which it will need to pass to msiexec.exe when launching the installation.
Regards,
Bogdan
FOLLOW US
Get the latest news in Application Packaging