0

I'm creating an app that can uninstall, remove and rename applications.

I get a list of them from Registry functions. I can delete them from the Registry, or rename them, but I can't uninstall applications that have an MSI, like Python or MySQL, for example.

With ShellExecute(), I can uninstall apps that have an uninstall string like "C:\Program Files\VideoLAN\VLC\uninstall.exe". But if an application has an uninstall string like MsiExec.exe /I{D5201299-C610-4861-BFB6-A85BCCC69046} then nothing happens.

I can't understand what I should do.

I can launch an MSI just by calling system(), like system("start MsiExec.exe /I{D5201299-C610-4861-BFB6-A85BCCC69046}"), but it doesn't work with uninstall.exe.

Official MSDN didn't help me in any way to understand that problem.

So my question is: How can I uninstall an MSI app with ShellExecute()?

Here is my code:

wstring uninstall_string;
ShellExecute(NULL, L"open", uninstal_string.c_str(), NULL, NULL, SW_SHOW);
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Does this answer your question? [Uninstalling an MSI file from the command line without using msiexec](https://stackoverflow.com/questions/450027/uninstalling-an-msi-file-from-the-command-line-without-using-msiexec) – Simon Mourier Oct 25 '21 at 12:52
  • Why `ShellExecute`? It has no useful means of indicating errors (hence the existence of `ShellExecuteEx`) and it ultimately just calls `CreateProcess` for this sort of task. Why not call `CreateProcess` directly and cut out the intermediary. – David Heffernan Oct 25 '21 at 13:22
  • But how can i launch a cmd with parameters from createprocess? – Count Zero Oct 26 '21 at 03:22
  • If you read the documentation for CreateProcess that should be obvious. Did you? – David Heffernan Oct 26 '21 at 07:51

0 Answers0