Add self-uninstall ability to MFC application by calling ShellExecute for MsiExec.exe


/ Published in: C++
Save to your folder(s)

Add self-uninstall ability to MFC application by calling ShellExecute for MsiExec.exe.
Useful for temporary apps that can be uninstalled after use.
The installation's GUID is required. This GUID is auto-created by Visual Studio when a Setup/installation project is created.


Copy this code and paste it in your HTML
  1. BOOL MyDlg::OnMenuUninstall( UINT nID )
  2. {
  3. // WinExec is obsolete.
  4.  
  5. ShellExecute(
  6. NULL, // hwnd
  7. "open", // operation/verb.
  8. "MsiExec.exe", // executable.
  9. "/x{FEF094C3-B58A-42e5-8170-659A670B25E6}", // parameters.
  10. "", // directory
  11. SW_SHOW ); // how to be displayed
  12.  
  13. // GUID comes from setup.vdproj file. Search for...
  14. // "ProductName" = "8:DCT Upgrade"
  15. // "ProductCode" = "8:{FEF094C3-B58A-42e5-8170-659A670B25E6}"
  16. return TRUE;
  17. }

URL: mfc uninstall

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.