Kamp
Posts: 23
Joined: Wed Mar 07, 2018 8:43 am

Custom action when patch is uninstall

Hello! I can not configure a custom action when I remove a patch. I added the "Run when patch is uninstalled (Windows Installer 4.5 or higher)" option for a custom action, but when I remove the current patch, I get an "The update package is not permitted by software restriction policy" error.
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action when patch is uninstall

Hello and welcome to our forums,

I'm not so sure why this happens. Could you consistently replicate the error on multiple machines? For testing purposes we always recommend to be used virtual machines with clean states so that when something goes wrong you can easily revert to a clean state of the virtual machine.

Please send us to support at advancedinstaller dot com the following resources so we can further investigate them:

1. the AIP (project file) of your old setup project
2. the AIP (project file) of your new upgraded setup project
3. the AIP (project file) of your patch project
4. a test case you follow to replicate the issue

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Kamp
Posts: 23
Joined: Wed Mar 07, 2018 8:43 am

Re: Custom action when patch is uninstall

In the test case, the error does not appear, but the script is not executed when patch 1.0.5 is uninstalled.
Attachments
Setup Test.zip
(28.88 KiB) Downloaded 292 times
Kamp
Posts: 23
Joined: Wed Mar 07, 2018 8:43 am

Re: Custom action when patch is uninstall

Tell me, please, what am I doing wrong?
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action when patch is uninstall

Hello,

Please accept my apologies for the delayed reply.

I've tested your sample and replicate the issue. There are two things you should be aware:

1. when you want to run a custom action on patch removal, besides checking the "Run when patch is uninstalled (Windows Installer 4.5 or higher)" option you should also NOT uncheck any of the predefined execution stage conditions; all execution stages must be checked otherwise, if the condition is not fulfilled (evaluated to true) during the patch removal stage (this is a maintenance mode) the action won't be executed
screenshot.jpg
screenshot.jpg (101.38 KiB) Viewed 9716 times
2. the custom action scheduled on patch removal should not make use of our temporary files support; this is because the temporary files are not extracted during a patch removal, this is a limitation of our temp file support

So, to achieve what you need you should make sure you check all the execution stage conditions for your custom action and instead of adding the BAT files as temporary files you can add them as regular files or try to use another custom action type (i.e. "Launch attached file).

If you have any further questions or doubts just let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Kamp
Posts: 23
Joined: Wed Mar 07, 2018 8:43 am

Re: Custom action when patch is uninstall

Hello, Daniel!

Thanks for the answer. I did the same, but I did not get the desired result.
When the patch is deleted, the error "Windows Installer" appears.
Tell me, please, what am I doing wrong?

More questions:
1) How can I find out the current version of the distribution when installing a patch, in order to execute or not a custom action?
2) How can I find out the version of the distribution that will be after the patch was removed, in order to execute or not a custom action?
Attachments
Setup Test.zip
(28.78 KiB) Downloaded 292 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action when patch is uninstall

Hello,

This seems to happen because you are using the formatted file reference of your BAT. Accordingly to Windows Installer docs this reference resolves to an empty string because the BAT component has an action state of absent (due to patch removal) and an install state of null (because the BAT component is not present in the target version of yoru product v1.0.0). In this case the reference will be resolved to empty string.

However, to workaround this you should simply set the "File To Launch" field of your custom action like this

Code: Select all

[APPDIR]Move1.bat
i.e. by using a formatted reference of the parent folder property.
More questions:
1) How can I find out the current version of the distribution when installing a patch, in order to execute or not a custom action?
2) How can I find out the version of the distribution that will be after the patch was removed, in order to execute or not a custom action?
I think this is not possible to achieve. Or at least we are unaware of how you could find out this info.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Kamp
Posts: 23
Joined: Wed Mar 07, 2018 8:43 am

Re: Custom action when patch is uninstall

Thank you, Daniel! Everything worked out.
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action when patch is uninstall

You are always welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Kamp
Posts: 23
Joined: Wed Mar 07, 2018 8:43 am

Re: Custom action when patch is uninstall

Hello, Daniel.
There was one more problem. Removing the patch at the "Finish Execution" stage does not make it possible to transfer the parameters to VBScript, which are registered in the "Action Data" field. Tell me how to do this at this stage?
Attachments
Setup Test.zip
(28.82 KiB) Downloaded 297 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action when patch is uninstall

Hello,

I think this happens because of a small bug in our app. When you set the action data field of a deferred custom action what we do is to create a "Set installer property action" which set the name of your custom action to use the action data. What happens is that we do not set the "Run when patch is uninstalled" flag for this set property action too, thus the ActionData is not set on patch uninstall.

We will try to add a fix for this in the future and update this thread when doing so.

Until then as a workaround you should proceed like this:
1. go to "Table Editor" page select the "InstallExecuteSequence" table
2. check which action in sequence precedes your "ExecuteScriptCode" action (by checking the sequence number); in your case this is "AI_DATA_SETTER_2"
3. go to "CustomAction" table and select the "AI_DATA_SETTER_2" action row
4. set its "ExtendedType" field to 32768
5. build again your projects

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Kamp
Posts: 23
Joined: Wed Mar 07, 2018 8:43 am

Re: Custom action when patch is uninstall

Hello,

It helped, thanks!
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action when patch is uninstall

You are always welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Kamp
Posts: 23
Joined: Wed Mar 07, 2018 8:43 am

Re: Custom action when patch is uninstall

Hello, Daniel!

When the patch is deleted, the search does not work.
In the example in the custom action "ExecuteScriptCode", the pop-ups are empty.
"ExecuteScriptCode_1" is not executed.
Attachments
Setup Test.zip
(28.63 KiB) Downloaded 288 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action when patch is uninstall

Hello,

Unfortunately this happens because on patch uninstall no search is executed, therefore your search property will not be populated.

The only workaround I can think of right now will be for your to create from scratch another custom action (scheduled to run on patch uninstall) which will perform the registry search and set the installer property to the search result.

Hope this helps.

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

Return to “Common Problems”