Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# uninstall event

Tags:

c#

Is it possible to catch the uninstall event and execute some code when the program starts uninstalling?

program is installed by autoinstall. i already try to use this

public override void Uninstall(
 IDictionary savedState
)

but it said that method can not be overriden becouse it does not exist.

like image 876
senzacionale Avatar asked Oct 26 '25 08:10

senzacionale


2 Answers

If you are talking about Setup projects in Visual Studio then look at this thread: Install directory from deployment projects. You can execute code on the install and uninstall using the Installer class.

like image 98
YWE Avatar answered Oct 28 '25 22:10

YWE


You should be able to do this using a System.Management listener for deletion of instances of Win32_Product. Take a look at this, you would need to use Win32_Product and __InstanceDeletionEvent though.

This applies to software installed using Windows Installer, at least. For others, you may have to brute force the registry settings or the like.

like image 36
Steve Townsend Avatar answered Oct 28 '25 21:10

Steve Townsend



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!