During installation "Modify" no uac elev on custom actions - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

todd.throne
Posts: 11
Joined: Tue Jan 18, 2011 6:48 pm

During installation "Modify" no uac elev on custom actions

Within Programs and Features on Windows 2008, after selecting "Change" (ie Modify) my custom action is not running with elevated privileges. My custom action is under InstallExecuteSequence - Install and call through the stdDllWrapper.dll into my helper dll. When the helper dll tries to modify the registry it gets and access denied error. The same custom actions run fine during the installation or the uninstall (remove) operations, it just fails during the modify. How do I fix this?

Thanks,
Todd
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: During installation "Modify" no uac elev on custom actio

For a custom action to run elevated you need to set it as "Deferred with no impersonation", this will make it run with admin rights under the SYSTEM account.

However, please note that deferred custom actions cannot access public properties, like immediate custom actions do.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
todd.throne
Posts: 11
Joined: Tue Jan 18, 2011 6:48 pm

Re: During installation "Modify" no uac elev on custom actio

Yes, my custom action is set to "Immediate execution" under execution options. Why does the same custom action run elevated during the installation? I have other custom actions all set to immediate execution and they run elevated during install and uninstall as well. It's only during the modify operation that the custom action is not being elevated. Why is that? It's almost like during the modify no attempt to run elevated is made at all, during installation and uninstall the usual dialog asking for elevated privileges is displayed by windows but no such dialog is displayed during modify.
todd.throne
Posts: 11
Joined: Tue Jan 18, 2011 6:48 pm

Re: During installation "Modify" no uac elev on custom actio

After searching around a bit, it seems maybe this is a limitation of windows within the "modify" and "repair" options from the Programs and Features dialog.

Here's a discussion that seems to be relevant;

http://stackoverflow.com/questions/8647 ... ermissions

My custom action needs to be able to access variables entered by the user, so unless there's a way to get this information to my custom action while being "deferred with no impersonation" then I don't see a solution.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: During installation "Modify" no uac elev on custom actio

Hi Todd,

If you want to use public properties in a "Deferred" custom action you need to use the Action Data field:
http://www.advancedinstaller.com/user-g ... rties.html

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
todd.throne
Posts: 11
Joined: Tue Jan 18, 2011 6:48 pm

Re: During installation "Modify" no uac elev on custom actio

I am using the custom action data field... The documentation says;

Deferred custom actions can receive information about the installation process, mostly only embedded in the CustomActionData property. However, this type of custom actions do not have access to installer properties.

In my testing if the execution options is set to anything but "Immediate execution", then the properties I'm passing to my custom action dll are empty (only from within the context of modify as mentioned before). I assume the note above from your documentation stating "mostly only embedded" is a round about way of saying you can only pass an "Inline Value" as a parameter to the custom action?
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: During installation "Modify" no uac elev on custom actio

Hello,

Custom actions that get executed in the deferred phase can get public property values( installation information ) in the CustomActionData property.
This property behaves like any other. You can append other properties' values( available in the immediate phase for example ) to it and then parse its value inside any deferred phase custom action.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
todd.throne
Posts: 11
Joined: Tue Jan 18, 2011 6:48 pm

Re: During installation "Modify" no uac elev on custom actio

Ok, so I added a property called CustomActionData under "Properties" on the "Install Parameters" page. I've tried setting its value to "" as well as "Testing". I then pass this property to my custom action as the only parameter (of type unicode string) and set my custom action to deferred (tried deferred with no impersonation as well). When my custom action gets called the value of the parameter passed to my custom action is garbage. What am I doing wrong?
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: During installation "Modify" no uac elev on custom actio

Hi Todd,

I'm afraid our explanations were not very precise regarding the CustomActionData property.

First of all, you don't need to set this property manually, as you did. The property is set automatically by the package when you set the field "Action Data" of your custom action, i.e. the one you have set as "Deferred with no impersonation". For example to pass the property APPDIR you need to set the field Action Data to "[APPDIR]".

If you want to pass multiple properties you can add them in the same field using a separator, like this: [APPDIR] | [MY_PROP].

Then, from your code you get the values of the property CustomActionData and parse it, as we do in the following example.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
todd.throne
Posts: 11
Joined: Tue Jan 18, 2011 6:48 pm

Re: During installation "Modify" no uac elev on custom actio

My custom action is under InstallExecuteSequence - Install and called through the stdDllWrapper.dll into my dll. My current "Action Data" value on the Custom Action Properties page is [&install_helper.dll]?D;PROPERTY;C;SetCustomerInformation;B;S;P;BCCA_NAME?B;S;P;CUST_PWD? This was set through the "Edit Function" dialog.

I don't see where to put the install properties I want to eventually end up in the CustomActionData property. Are they Arguments to my dll function? I doesn't sound like it.

Also, once the values are in the CustomActionData property am I suppose to use MsiGetProperty() to access it? I thought only UI Custom Actions get passed an MSIHANDLE? Is there a way to get is if its not passed to me?
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: During installation "Modify" no uac elev on custom actio

Hello,

If you are using "Call a function from a standard dll"( user guide reference ) predefined custom action, you can easily include a public property as an argument from the Edit Function Argument Dialog( Value Binding section ):
http://www.advancedinstaller.com/user-g ... ialog.html
Also, once the values are in the CustomActionData property am I suppose to use MsiGetProperty() to access it? I thought only UI Custom Actions get passed an MSIHANDLE? Is there a way to get is if its not passed to me?
This would be the correct approach to get a public property when including a Win32 .DLL custom action.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
todd.throne
Posts: 11
Joined: Tue Jan 18, 2011 6:48 pm

Re: During installation "Modify" no uac elev on custom actio

I have two problems, the first is how to get the data I want into the CustomActionData property through the "Action Data" of a stdDllWrapper.dll custom action. The second is how to get the data out of CustomActionData from my custom action dll with MsiGetProperty() without an MSIHANDLE.

I'm going to try the questions one more time and if that doesn't work I'm going to remove the modify option completely and make our customers uninstall and reinstall to reset installation parameters.

First problem. Here is the current value of my "Action Data" field, built from the edit function dialog;

[&install_helper.dll]?D;PROPERTY;C;SetCustomerInformation;B;S;P;BCCA_NAME?B;S;P;CUST_PWD?

BCCA_NAME and CUST_PWD are arguments(public properties) to my custom dll that I can no longer access as I'm changing the "Execution options" from "Immediate" to "Deferred with no impersonation" and deferred custom actions can't access public properties.

These properties I want to end up in the CustomActionData property, do I pass them as an argument? Is there another option I'm not seeing because I'm using version 7.7? If I do pass them as an argument what type are they and how to you get multiple properties in one argument? (ie [BCCA_NAME]|[CUST_PWD]) ? Can you modify the above "Action Data" field to show me how exactly how to do it?

Second problem. MSIHANDLE is not passed to my custom action. Is there a global for this handle I can access? Is there any other way to get it?
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: During installation "Modify" no uac elev on custom actio

Hello,
These properties I want to end up in the CustomActionData property, do I pass them as an argument? Is there another option I'm not seeing because I'm using version 7.7? If I do pass them as an argument what type are they and how to you get multiple properties in one argument? (ie [BCCA_NAME]|[CUST_PWD]) ? Can you modify the above "Action Data" field to show me how exactly how to do it?
Using the predefined "Call a function from a standard dll" custom action you can use the "Edit Function" dialog to specify public properties arguments. These arguments will be passed to the function defined in your standard .DLL. This is how you can get installer information( public properties ) into this type of predefined custom action, forget CustomActionData.

Also,it doesn't matter if the custom action is deferred, the arguments will be passed accordingly. You can read how to use this predefined custom action in the following article:
http://www.advancedinstaller.com/user-g ... ll-std-dll
Second problem. MSIHANDLE is not passed to my custom action. Is there a global for this handle I can access? Is there any other way to get it?
Can you please specify why do you need to use MSIHANDLE type for a "Call a function from a standard dll" predefined custom action? You can specify the argument's data type( Integer, Boolean, etc ) from "Edit Function Argument Dialog":
http://www.advancedinstaller.com/user-g ... ialog.html

We recommend you first try new functionality onto a test project before implementing it onto your main one. This way you can fully understand how it works thus making sure you avoid any unwanted unexpected behavior.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”