• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 757
  • Last Modified:

C# uninstall a program on Windows 7

I would like to find a way to uninstall a software by looking up the registry and find the msi file to launch with the uninstall commandline switch.
Basically, I can't find an elegant way to look into the appropriate registry path to find this info.
I know the place in the registry is different on my Windows 7 64-bits that what I've found on the Internet so far.
Is there a way compatible with all the versions of Windows?
I would do the lookup based on the msi name.
Thanks for your help
  • 2
1 Solution
AndyAinscowFreelance programmer / ConsultantCommented:
If it is installed via an msi then it should appear in the list of programs available for de-installation from the control panel.
Are you saying it doesn't ?
Or do you want to do it programatically ?
jmlacosteAuthor Commented:
Hi AndyAinscow

Yes I would like to do it programmatically from looking up an MSI name in the registry.
The software is available in the de-installation screen in control panel.
I was just saying that the registry path that I've found on the Internet to check what software is installed is different on my version of windows: I can find my software in HKLM\Software\Wow6432Node but the various solutions online are talking about something more like this: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Hence I'm looking for a way to programmatically uninstall a specific MSI on all Windows versions (XP, Vista, 2003...)

Thanks again ;)
Look at the function MsiEnumProductsEx() if you don't know the product code.
Then use MsiInstallProduct() to install or uninstall product.

You can find a .NET declaration of these functions on pinvoke.net
E.g. http://pinvoke.net/default.aspx/msi/MsiInstallProduct.html
jmlacosteAuthor Commented:
I didn't have the chance to actully implement this solution but it looks like the right direction to look into.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now