Answered by:
Uninstall

Question
-
Is it possible to run uninstall from c# code?
Sunday, September 27, 2009 8:02 AM
Answers
-
The short answer is that I wanted to ininstall an MSI-based setup from C#, there are a couple of ways to try:
1) The real programmatic way, which is to P/Invoke into the Win32 API to do this:
UINT n = MsiConfigureProduct(productid, INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT);
where productid is the ProductCode guid of your setup project.
or this:
2) A Process.Start of msiexec.exe /x {productid}
Phil Wilson- Marked as answer by gadgallea Sunday, October 4, 2009 7:26 AM
Thursday, October 1, 2009 10:49 PM
All replies
-
Hi gadgallea,
Assuming that you mean uninstalling a msi package, you can use Process.Start method to call the msi installer, if that is already installed on the machine, it will be given an uninstall choice.
If that is not the case, please clarify a bit.
Thanks.
Figo Fei
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.Monday, September 28, 2009 5:35 AM -
I have an installed program on a machine. After installation I run activation wizard that encrypt files and copy them to the destination folder.
If the user chooses cancel than i want to roll back all operation - uninstall the program and delete all files.
Is it possible to do that through code?Wednesday, September 30, 2009 8:36 AM -
Hi gadgallea
I guess still not sure what exact you want.
What is "activation wizard", is it part of the MSI setup process?
The actions being done in the msi setup can be rollback if the installation is failed, MSI does it for you, you don't need to handle it yourself.
Thanks.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.Wednesday, September 30, 2009 9:19 AM -
The activation wizard is installed by the msi setup. After the installation finish, the activation wizard run and copy more files from the cd to the installation folder.Wednesday, September 30, 2009 11:20 AM
-
Hi
If you're the developer and responsible of the deployment, you can add the actions into the install custom actions(copy the files), and reverse the actions (remove the files) in the uninstall and rollback custom action of the msi, you can see How to: Add and Remove Custom Actions in the Custom Actions Editor for detailed information.
If you just want to delete those files in the program, System.IO.Delete should meet the need.
Thanks.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.Thursday, October 1, 2009 1:39 AM -
Lets say i am installing 2 programs in different locations. Can i uninstall one program with the other one?Thursday, October 1, 2009 1:01 PM
-
The short answer is that I wanted to ininstall an MSI-based setup from C#, there are a couple of ways to try:
1) The real programmatic way, which is to P/Invoke into the Win32 API to do this:
UINT n = MsiConfigureProduct(productid, INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT);
where productid is the ProductCode guid of your setup project.
or this:
2) A Process.Start of msiexec.exe /x {productid}
Phil Wilson- Marked as answer by gadgallea Sunday, October 4, 2009 7:26 AM
Thursday, October 1, 2009 10:49 PM -
Thank you very muchFriday, October 2, 2009 3:34 PM