Hello Roden and welcome to our forums,
Please note that the encountered behavior is the expected one and please allow me to explain why.
First of all, I'm gonna explain some terms so we can better understand why this is happening.
MSI - bunch of actions (both standard and custom) that run in a
sequence (order)
normal files - files that you add in your project and that are added during the
"Add resources" action group
- Screenshot_60.png (144.68 KiB) Viewed 8296 times
temporary files - files that are extracted much earlier than normal files so they can be used by different custom actions in your project. These are also removed when the installation ends.
Temporary Files Operations in the Files and Folders Page
Temporary files are copied on the machine during the
CostFinalize standard action, which is part of the
"Paths Resolution" action group.
Now, temporary files are copied on the machine in the predefined folder location, the temporary folder.
In your case, you have changed this location to a location that does not exist - so what does the installer have to do? Well, it basically has to create it.
Since your installation type is set to per-machine, the "Application Folder" will be a in a per-machine location that requires admin rights (as opposed to the %temp% folder, which doesn't).
The MSI installation consists of two processes:
- the Wizard Dialogs Stage, where the dialogs are spawned
- the Install Execution Stage, where the actualy installation logic happens
Now, these two processes are connected by the
"Install" button. When this button is pressed, the setup elevates (gains admin rights) and then goes into Install Execution Stage.
Now that all these are clear, let's discuss your scenarios:
When a regular user runs the MSI, a UAC prompt will show up to ask for an admin's permission.
After an admin accepts this, the temporary files don't get placed inside the APPDIR folder during installation.
- Screenshot_61.png (25.71 KiB) Viewed 8296 times
As we can see in the attached screenshot, the setup will try to create the folders in a location that requires admin rights before actually having admin rights, because the elevation happens when the user presses the
Install button (if not launched elevated from the start).
In contrast, when an admin user runs the MSI, no UAC prompt shows up as expected, but it was still able to place the temporary files in the APPDIR folder.
As you later mentioned, this is not quite true and this works basically the same as before - the only difference being you're not prompted for admin credentials, but the UAC still appears and you have to confirm.
Further tests show that this is actually incorrect.
The temporary files are only placed inside the APPDIR folder when the msi is run with the following steps, regardless if the current user is admin or not:
1. Open CMD in admin mode
2. Execute msiexec /i <msi>
This works because the MSI (including the Dialogs Stage process) will inherit admin rights from the CMD prompt and therefore will have the required rights to create the folder.
Hope the explanation helps!
Best regards,
Catalin