elevated immediate custom action - Advanced Installer Community
fly
Posts: 10
Joined: Wed May 07, 2014 7:25 pm

elevated immediate custom action

I have read the documentation that explains you cannot elevate a custom action to run as admin if it is executed as immediate (as apposed to deferred, which will allow you to run it under the local system account).

My script can be executed as a batch or powershell.

Is it possible to pass in the "runas" command in powershell script parameters in order to elevate it?

My script maps a network drive and has to be run immediately. There are two accounts on the target machine, standard user and admin. The drive needs to be mapped for both. I have no issues mapping for the standard user.

Any advice on how to run a script elevated immediately? Thanks!
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: elevated immediate custom action

Hi,

In order for your script to run with full privileges, you can place it after the "Install Execution Stage -> Searches" action group in the custom action page (it will inherit the main package's privileges) or you can go in the Install Parameters page, check the "Run as administrator" option for your package, then all the custom actions will have full privileges.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
fly
Posts: 10
Joined: Wed May 07, 2014 7:25 pm

Re: elevated immediate custom action

I have tried setting "Run as administrator" on the install page as suggested, but then my scripts that need to be ran for a standard user do not execute properly.

My script maps a network drive that needs to be mapped before files can be installed. If I place my script after Install Execution Stage -> Searches, it will fail because the drive is not found during the paths resolution that happens in the wizard dialogs stage.

Maybe I am not understanding something... I am doing a single exe with resources inside (but this isn't really necessary, I could do a single MSI). I am doing basic UI and progress in the EXE bootstrapper. Maybe if I changed this configuration, I would not have as many problems?

Suggestions?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: elevated immediate custom action

Hi,

If you want to have a single MSI and run it with basic UI, you can select the "Single MSI" option in the Media page and the "Limit to basic user interface (simple progress and error handling)" option in the Install Parameters page.

In this case only the "Install Execution Stage" action will be executed, so placing your custom action after the "Install Execution Stage -> Searches" action group is the right approach.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
fly
Posts: 10
Joined: Wed May 07, 2014 7:25 pm

Re: elevated immediate custom action

Thank you for your reply. I will try this approach and report back. :D

Return to “Common Problems”