stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Launch app as current user after escalation in Vista/Win7

My installer requires Admin and installs for the machine.

If a limited user tries to install, Vista/Win7 prompts for escalation to Admin, at which point, if the user has credentials, installation can proceed. There's nothing I can do to stop this nor should I.

Problem is, my installer starts the app when installation is complete (using the standard Finish page checkbox). This means that in the escalation scenario, the app is invoked as administrator, has elevated privileges, writes to the Admin's users settings in registry, etc.

How can I get the automatic launching of the app to invoke in the current user instead of the escalated user required to run the installer?
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Launch app as current user after escalation in Vista/Win7

I found the solution to this.

In addition to having set Prerequsisites/Launch Conditions/Run only if user has administrator privileges (which only affects XP), I had Install Parameters/Execution Level set to Require Administrator. This caused escalation to happen immediately, and the elevated token to be applied to all subsequent actions, including launching my app.

By changing the bootstrapper execution level to As Invoker, when a limited user under Vista launches the installer, it no longer escalates immediately. Instead, escalation occurs after clicking Install, and escalation applies to a separate process, which apparently does not also launch my app.

When time comes to finally launch my app, the non-escalated process is doing it, and my app is launching as the logged on user, as desired.
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Launch app as current user after escalation in Vista/Win7

Hello,

Starting with the 15.2 version of Advanced Installer released on August 13th, 2018, the support to launch app without admin rights for predefined "LaunchFile" custom action has been added.

Basically, no matter if the installer is running elevated or not, the launched exe will always be launched without admin rights when the predefined LaunchFile custom action is used.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TheM
Posts: 19
Joined: Wed Mar 02, 2016 12:46 am

Re: Launch app as current user after escalation in Vista/Win7

Hi Dan,

How do I get the old behaviour back?

If a user ticks the checkbox on Finish page to launch my application after the installation I want it to run at the same level that installer had.

Regards,
Harvey
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Launch app as current user after escalation in Vista/Win7

Hi Harvey,

Can you please give us more details about your scenario? Is there any reason for such a behavior?

If your package requires admin privileges, that means you always need admin privileges to install your application. In this case you can enable the Run as admin from the FinishDlg.

Is there other scenario? If Yes, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TheM
Posts: 19
Joined: Wed Mar 02, 2016 12:46 am

Re: Launch app as current user after escalation in Vista/Win7

Hi Dan,

Application does not have to be installed as admin but it has additional features enabled only if it is ran as admin.

Users installing as admin expect to have those features available immediately if they choose to start the app via the checkbox, otherwise checkbox start option is a bit pointless for them.

Cheers,
Harvey
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Launch app as current user after escalation in Vista/Win7

Hi Harvey,

In this case, you can create a custom action that will detect if the process is running elevated or not.

Also, you will have 2 custom actions of launch File custom action added as custom actions without sequence. Each custom action will launch your application when the user will press the Finish control. One custom action will have the Run as admin flag enabled, the other one will not have this flag enabled.

Based on the result from the custom action you will condition the launch file custom action accordingly.

For a detailed reply, please check Launch app in the context installation privileges at the end of the installation forum thread.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TheM
Posts: 19
Joined: Wed Mar 02, 2016 12:46 am

Re: Launch app as current user after escalation in Vista/Win7

Hi Dan,

I got it working following the instructions in that forum thread.

Thanks,
Harvey
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch app as current user after escalation in Vista/Win7

You are always welcome, Harvey.

We are glad you got this working.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”