• Welcome to Support Forum: Get Support for Patch My PC Products and Services.
 

Prevent post-installation script to run when installation failed

Started by PS_Alex, August 05, 2024, 03:18:48 PM

Previous topic - Next topic

PS_Alex

Hello!

We observe that there is no option to prevent the execution of a post-installation (or a post-uninstallation) script if the main software installation/update exits with a failure code.

For example, say a post-uninstallation script that do some additional cleanup after the uninstallation of the main program had finished. If the uninstallation fails with a RC = 1603, then the post-uninstallation script would still be executed.

What would be your recommendations to handle such a situation?
Could an option be added in the Publisher to prevent a post-(un)installation script to run with RC different than a success code? (And if so, could it consume the return code as set in the "Modify return code" property of an update/configmgr app?)

Thanks!

Andrew Jimenez (Patch My PC)

Hello, we have a similar idea here: https://ideas.patchmypc.com/ideas/PATCHMYPC-I-4019

Please vote on that idea and provide additional feedback, and I'll see if I can get it in front of the devs. Thanks!


Michael (Patch My PC)

Hi PS_Alex,

That is something that has been mentioned before. There is an idea on our Idea's page for an option just as you described. I highly suggest that you head over there and give it an upvote as our Dev team does use this to Prioritize what they work on.
https://ideas.patchmypc.com/ideas/PATCHMYPC-I-4019

Currently what you can do is pass the 'ReturnCode' from the main installer to your script and act accordingly. Below is a link on you can do that and also an example of a script taking in that return code and doing something with it.
Pass Variables into Pre and Post Scripts - Patch My PC

You could have your script do this and do a check at the beginning to only run the main part of the script if you get a successful ReturnCode from the Main script.

PS_Alex

Thanks to you both!
I did not find the idea with the search terms I used; I'll definitely go vote for it!

And yeah, that's what I was expecting for the post-(un)installation script: let it start and pass the return code as a parameter, and react accordingly (i.e. proceed with additional tasks if RC is success, or quit and do nothing if the RC is an unexpected one). We'll work on that direction for now until (hopefully) another solution comes up. :)