vbjeff
Posts: 23
Joined: Tue May 14, 2013 3:08 pm

Update without elevation then run as standard user.

I want to update my software without elevation, and then run my software as a standard user. I followed the directions to "How to handle updates without elevation?" so that I can update my software without any UAC prompts. I then want to restart my software after the update as a standard user, but it was restarting as the "Local System" user because the "Local System" user is the account that runs the updater service (making my software not visible). I read that the RunAsUser command can not be called from the Local System account.

To get it working properly I had to add a custom action to call a ".NET Installer Class action" that would use a WMI query to find the user that is logged-in, and then add a task to Task Scheduler (as the logged-in user) that runs once (right after the installation finishes), and then the task deletes itself after it expires.

Is there a better way to accomplish this, or is this the best/only way?

Thanks,
Jeff Becker
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Update without elevation then run as standard user.

Hello Jeff,

Indeed, when you use our updates without elevation feature the updates installation is entirely performed under the Local System account context. Therefore any custom action triggered by the installation process will run under the Local System context.

I'm not aware of any other better way/solution than a custom action you can use to achieve what you want.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vbjeff
Posts: 23
Joined: Tue May 14, 2013 3:08 pm

Re: Update without elevation then run as standard user.

The current WMI query I use to find the currently logged-in user is:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem");
ManagementObjectCollection collection = searcher.Get();
return (string)collection.Cast<ManagementBaseObject>().First()["UserName"];

The only problem is that multiple users can be logged into a computer at one time. Do you know if there is a way to determine the user account that originally launched the updater?

Thanks,
Jeff
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Update without elevation then run as standard user.

Hello Jeff,

I'm not aware of any way you can determine the user account which initially launched the Updater.

As another workaround, you can try to use the "Auto Close Applications" tab from the "Updates" page of your updates configuration project. You can try to check the "Restart Always" option and see if this helps.

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

Return to “Common Problems”