lpg
Posts: 2
Joined: Fri Aug 07, 2009 3:34 pm

Launch Application vs Impersonation

Quick summary: if my installer launches an executable at the end of the install process, it uses the wrong account, either SYSTEM or the admin account.

Full story:
  • - Using AI 7.1.3
    - "Installation Type" set to "Per-machine only (fails is user is not administrator)"
    - The installer has a Custom Action to launch an executable after installation completes ("Installed Custom Action").
I followed the documentation, which states
If the installation will run on Windows Vista the custom action should be moved under "InstallExecuteSequence" -> "PublishProduct". Also, it should be set as "Deferred with no impersonation".
Running the installer on Vista, using a NON-admin account (meaning I get prompted to provide admin credentials at the start of the install process), I run into this problem: when the executable gets launched, it's using the SYSTEM account instead of the account of the currently-logged-in user.

If I set to "Deffered" instead, it ends up using the administrator account, which is better in some ways, worse in others.

Moving the Custom Action under InstallFinalize doesn't help; I get no "no impersonation" option, admin account gets used. Same if I instead use the ExitDialog's "Launch Application" feature.

Did I miss a magic option? Is this a limitation of Advanced Installer?

--
LPG
http://www.macadamian.com/
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Launch Application vs Impersonation

Hello,

This is no limitation of Advanced Installer. It is normal that while running Deferred, your custom action will inherit your installer's privileges.
Please note that since your "Installation Type" is set to "Per machine", your installer runs as Administrator, thus, your custom action will inherit this and also run as Administrator.

Running as "Deferred with no impersonation" means it will run under the local SYSTEM account, which is again normal, as stated here in the "Execution Options" section.

In Windows Installer, a custom action can only run under the same account under which the installer is running, or under the local SYSTEM account.

However, you can programatically impersonate another user from within your custom action. For example you can use the CreateProcessAsUser Function to achieve this.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
lpg
Posts: 2
Joined: Fri Aug 07, 2009 3:34 pm

Re: Launch Application vs Impersonation

Running as "Deferred with no impersonation" means it will run under the local SYSTEM account, which is again normal, as stated here in the "Execution Options" section.

In Windows Installer, a custom action can only run under the same account under which the installer is running, or under the local SYSTEM account.
OK, so it's a limitation of installers in general? This seems to severely limit the usefulness of the ExitDialog's "Launch Application" functionality and of "launch file" custom actions.

If a Regular User asks the installer to launch the application after installing it, he's going to expect that it will function the same way as if he launched it manually. But in the case of a "per-machine-only" installer, this won't be the case in at least one important respect: the application will be using the wrong HKEY_CURRENT_USER (either the admin account's or the system account's). One can argue that the user gave admin credentials, so he should know the app won't run for the right user; but I think that would be expecting too much of the user.

May I suggest extending the manual's "use Deferred With No Impersonation" note with a clarification of the limitations this comes with?
However, you can programatically impersonate another user from within your custom action. For example you can use the CreateProcessAsUser Function to achieve this.
But I would have to programatically determine which user I should be impersonating; any suggestion for that?

Again: the user just ran my installer, and gave admin credentials when he was bothered for them. As far as he's concerned, he's the one installing the app, he'll expect it to get launched for himself, not the admin user, and certainly not "the system account", of which he's probably never even heard of. Asking him e.g. to select his own account from a combobox wouldn't be in good form...

Presumably, at some point the installer explicitly makes the switch from "running for the current user" to "running for the admin user"; it's unfortunate that there's no built-in functionality for reverting back to the "current user" to perform actions...
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Launch Application vs Impersonation

Hello
May I suggest extending the manual's "use Deferred With No Impersonation" note with a clarification of the limitations this comes with?
We will consider adding this improvement to our guide in the future. Thank you for your suggestion.
But I would have to programatically determine which user I should be impersonating; any suggestion for that?
In order to achieve this you will have to:
- on the Custom Actions page, right click InstallUISequence->Show Standard Action->Begin
- now add a new "Property Set with Formatted" Custom Action under the "Begin" Standard Action
- in the "Property Name" field place a property name, say MYUSERNAME
- in the "Formatted text" field place [%UserName] which is the %UserName% environment variable which holds the name of the current logged in user
- the MYUSERNAME property will now hold the current logged in username as its value.
- you can then access the MYUSERNAME property from within your custom action which can recieve the MSI handle.
Here is an example of a C++ DLL Custom Action.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Yrlec
Posts: 30
Joined: Wed Jun 20, 2012 3:49 pm

Re: Launch Application vs Impersonation

Has this been solved since it was discussed the last time? We face exactly the same problem and having to create custom DLL to solve something like this sounds very cumbersome.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Launch Application vs Impersonation

Hello,

In order to run your custom action under the current logged on user you can simply add it after "Install Execution Stage -> Finish Execution" actions group (as immediate).

Let us know if this helped, otherwise please give us more details about your scenario.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Yrlec
Posts: 30
Joined: Wed Jun 20, 2012 3:49 pm

Re: Launch Application vs Impersonation

Great, I got it working now! It already had the action at that particular place. However, the setup was configured to always run as admin. If I changed it to elevate permissions after launch it worked.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Launch Application vs Impersonation

I'm glad you sorted this out.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dskrizhewsky
Posts: 1
Joined: Tue May 20, 2014 6:27 pm

Re: Launch Application vs Impersonation

Hello,

I tried the steps described in this thread

- added custom action "Lunch installed file" after the "Install Finalize" section
- Excecution time "Immediately"

The application keeps starting with augmanted priveleges. What I'm doing wrong and how to make it work? Advanved Installer ver 11.1

Regards
Dmitry
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Launch Application vs Impersonation

Hello Dmitry and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

This may happen if you have enabled the "Run As Administrator" option of your "Launch File" custom action. If this is not the case, can you please send us the .aip (project file) to support at advancedinstaller dot com so we can investigate it?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”