kumo
kumo

Reputation: 1

provide "cancel the installation" option in a C# application

I have a C# win forms application which validates a license file. I am running that application at the beginning of the installation of a product as mentioned here: http://support.microsoft.com/KB/827018

I want to provide an option to exit the installation or cancel the installation if the license is not valid. How can I cancel the installation from my application? Or do you have any suggestions?

Upvotes: 0

Views: 131

Answers (1)

PhilDW
PhilDW

Reputation: 20780

Visual Studio setups don't let you run code during the UI part of the install, so you cannot validate the license in the UI.

Also, there is no "before the install" in Visual Studio custom actions because they all run after the files have been installed. You can write a custom action to validate the PIDKEY property (which is what it's called). If you fail it, then throw an InstallException and the entire install will roll back and uninstall, but that's a terrible unfriendly user experience.

So there is no good answer. People using VS setups can have the app validate a license key and refuse to run if it's not correct. The alternative is to figure out how to use an MSI file editor like Orca to manually add a vbscript custom action that will run when the Next button is clicked and disallow the next dialog if it's not valid, and that is extremely complicated.

Upvotes: 1

Related Questions