Is this possible to put any scripts with the Setup Project in .NET C# so that I can delete couple of rows from a table or to delete the entire tables from database while uninstalling the setup from control panel? I need all the data to be removed from its database when the windows application is uninstalled
-
When you say "does not work", do you actually mean "is not called"? A few trouble shooting tips for custom install actions: 1. You can call System.Diagnostics.Debugger.Launch() from within your Uninstall method to force a breakpoint during the uninstall. 2. If it doesn't break at that line you should confirm that your Custom Uninstall Actions in the setup project is wired correctly. If both of those work, all you need to do is connect to whatever flavor of Db driver you currently use and perform the necessary actions. – Matt Ringer Jun 10 '14 at 16:22
-
I tried as you said, and it is working now. Thanks – Dani Mathew Jun 16 '14 at 14:01
-
Possible duplicate of [How can I remove all traces of a ClickOnce application from a customer's computer?](http://stackoverflow.com/questions/5584030/how-can-i-remove-all-traces-of-a-clickonce-application-from-a-customers-compute) – Dani Mathew Oct 27 '16 at 09:03
2 Answers
You may have to define exactly what "it does nor work for me" means. That code is an uninstall custom action, but it won't be called unless you've added it to the setup project as an uninstall custom action, if that's what you mean by it not working. This stuff does work, assuming you add it as an uninstall custom action.
Another way in which it will not work is that you probably won't see a console.writeline working. This is not application code running in the interactive user's shell. This is a callback from an msiexec.exe process running with the system account, so it most likely won't let you do anything to interact with the interactive user's desktop, and it's not clear to me what happens if you attempt to write to the system account's console because I doubt that it has one. That also means that if you're going to add code to delete tables from the database then the database needs to allow access by the system account, something that might not be allowed by default.

- 20,260
- 1
- 18
- 28
Just delete tables from sql and then do unistallations
drop tablename delete *row from tablename where condition

- 11
-
I have checked everywhere, can anyone give an idea on this. I can elaborate the situation if anybody wants. – Dani Mathew Jun 10 '14 at 11:57