shahviral6438
Posts: 9
Joined: Mon Mar 23, 2020 8:13 am

Custom action throwing error while installing Patch

For our project, we are using Advanced Installer 16.5 to generate installation exe from AIP file. We are also using same AIP file to generate patch. Install, Uninstall and Patch runs under Admin privileges.

In AIP, we have written a custom action, which does some registry clean-up. I have attached the screenshot of configuration of same custom action. (Image1). I have also attached the c# code for same custom action. (Image2)

Issue is, same custom action is running successfully while installing, uninstalling and in upgrade scenarios. But it is throwing below error while installing Patch:

Begin RegistryCleanUp
Exception thrown by custom action:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.SecurityException: Requested registry access is not allowed.
at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at CustomActions.RegistryCleanUp(Session session)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at Microsoft.Deployment.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint, IntPtr remotingDelegatePtr)
CustomAction RegistryCleanup.CA.dll returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)


Any pointer to fix this issue?
Attachments
image2.jpg
image2.jpg (206.04 KiB) Viewed 6677 times
image1.jpg
image1.jpg (153.09 KiB) Viewed 6677 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action throwing error while installing Patch

Hi and welcome to our forums,

From what I can see in the installation log there is a permissions issue on the related registry key the custom action is trying to delete.

Could you enable the "When the system is being modified (deferred)" and "Run under the Local System account with full privileges (no impersonation)" options for your custom action and then rebuild your updated setup project and your patch project and see how this works for you?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
shahviral6438
Posts: 9
Joined: Mon Mar 23, 2020 8:13 am

Re: Custom action throwing error while installing Patch

Hi,

I tried above option and it did not worked. I also added another custom action with suggested configuration and added a condition to run it only for Patch scenario but still no luck. So at the end, I had to skip this custom action for Patch scenario as of now.

Thanks,
Viral Shah
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action throwing error while installing Patch

Hi Viral,

Thank you for your follow up on this.

Do not hesitate to get back to us if you want us to further investigate this scenario.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
shahviral6438
Posts: 9
Joined: Mon Mar 23, 2020 8:13 am

Re: Custom action throwing error while installing Patch

For now, I have skipped RegistryCleanUp custom action in case of Patch scenario as suggested option did not worked. But now, I am running into different issues.

We are using custom actions to set user password for services those are being installed / updated during Install / patch of exe.
Image1 and Image 2 are the configuration and code for the same.

And at the end, we have another custom action to Start all services with configuration and code given in Image3 and Image4.

But StartServices step fails with error “Cannot open {firstServiceName} service on computer '.'". If I try to start service manually, than I get error The service did not start due to a logon failure..

One point to note is, all services are running under different user account (which is already created as part of pre-requisites) and not under local user account. What I have noticed is, all custom actions, which needs admin privileges are needed, are not running successfully.

Am I missing anything here? Any help / pointer will be much appreciated.

Thanks,
Viral Shah
Attachments
image3.jpg
image3.jpg (103.42 KiB) Viewed 6649 times
image2.jpg
image2.jpg (125.84 KiB) Viewed 6649 times
image1.jpg
image1.jpg (132.6 KiB) Viewed 6649 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action throwing error while installing Patch

Hi Viral,

I cannot say what could go wrong. Just please make sure that your set password custom action runs before the start service one.

Otherwise I would suggest you to try troubleshooting your set password custom action code and see if there is any failure.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
shahviral6438
Posts: 9
Joined: Mon Mar 23, 2020 8:13 am

Re: Custom action throwing error while installing Patch

We re-ordered custom actions and made sure that password setup and start services custom action runs at the end of execution.
After above changes, we were able to fix this issue.

Thanks for the help,
Viral Shah
Catalin
Posts: 6584
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom action throwing error while installing Patch

You are always welcome, Viral.

We are glad this is working as expected for you now.

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

Return to “Building Installers”