benjy
Posts: 35
Joined: Mon Nov 02, 2009 12:25 pm

Custom Actions under "Run As Administrator"

Hi,

I'm having a problem with our MSI package that installs a simple executable and I hope someone can help...

Part of the installation process is a custom action that copies, when present, a file from the source directory (i.e. the directory from where the MSI is located) to the target directory. The custom action is written in C# in an assembly that is compiled to a DLL using WiX Toolkit. The DLL is then attached as a native DLL to the MSI, from which the custom action is called.

In addition to this, the MSI is conditioned so that the application can be installed either for the current user or for all users.

The problem we are having is as follows:

1) A normal domain user (i.e. non administrative privileges) launches the MSI installer.
2) The user selects the "install for all users" option, which means that the application files are written to Program Files.
3) The install button correctly shows with the UAC shield and when clicked, a prompt for credentials is displayed.
4) The installer proceeds normally and the application files are correctly installed (to Program Files) but our custom action fails citing insufficient permissions:

Code: Select all

Unexpected error occurred: Access to the path 'C:\Program Files (x86)\Symprex\Email Signature Manager Agent\agent.ini' was denied.
(This is output from the verbose log written by the custom action; the text is the error message in the exception thrown.)

The same problem occurs if you use "Run As Administrator". However, it does not occur if runas is used (in a command prompt) to launch msiexec to install the package.

Does anybody have any idea why this would be happening? I would have thought that the custom action, being in a DLL, would have the same privileges as the installer. Is there some option that I can change on the custom action to prevent this problem from happening.

TIA,

Ben
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Actions under "Run As Administrator"

Hello Ben,

This may happen if your custom action is not executed in the deferred stage of the installation. Can you please make sure the "When the system is being modified (deferred)" execution time option was selected for your custom action? If not, please use this option and see if this helps.
The same problem occurs if you use "Run As Administrator". However, it does not occur if runas is used (in a command prompt) to launch msiexec to install the package.
If you are referring to our "Run as administrator" option from "Install Parameters" page, then please note that this option will work only when you build and launch an EXE setup package. This option cannot be activated for the MSI setup package types.

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Silvia
Posts: 2
Joined: Mon Oct 21, 2019 3:23 pm

Re: Custom Actions under "Run As Administrator"

Hi I'm having exactly the same issue but my script is a javascript one and I also need the Installer paramenters. How can I do that? Also if it makes any changes we are using version 10.2 ( I know -_- )
Silvia
Posts: 2
Joined: Mon Oct 21, 2019 3:23 pm

Re: Custom Actions under "Run As Administrator"

Hi Daniel,

I'm having exactly the same problem but I'm trying to run some javascript as a Installed native DLL. My only difference is that I need the Installer Parameters so as far as I understood I can use the Deferred mode. Is there a way I can run my script in the with admin privileges and also access the Installer Parametners?

Thanks,
Silvia
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom Actions under "Run As Administrator"

Hello Silvia and welcome to Advanced Installer forums,
I'm having exactly the same problem but I'm trying to run some javascript as a Installed native DLL. My only difference is that I need the Installer Parameters so as far as I understood I can use the Deferred mode. Is there a way I can run my script in the with admin privileges and also access the Installer Parametners?
Unfortunately, properties can not be accessed during the deferred stage of the installation process. However, exception to this rule is the "CustomActionData" property.

For more information about this matter, please have a look over our "How to access installer properties from deferred custom actions".

Hope this helps.

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

Return to “Common Problems”