How to uninstall MSI using its Product Code in c#

前端 未结 4 2112
旧巷少年郎
旧巷少年郎 2020-12-02 02:15

I know We can uninstall a windows application using its MSI by passing command arguments as follows,

Process p = new Process(); 
p.StartInfo.FileName = \"msi         


        
4条回答
  •  臣服心动
    2020-12-02 02:43

    Along the lines of PhilmE's answer, Windows Installer XML (WiX) ships the Microsoft.Deployment.WindowsInstaller interop library as part of Deployment Tools Foundation (DTF). This skips the COM interop and encapsulates the Win32 API instead.

    using Microsoft.Deployment.WindowsInstaller;
    
    public static void Uninstall( string productCode)
    {
        Installer.ConfigureProduct(productCode, 0, InstallState.Absent, "REBOOT=\"R\" /l*v uninstall.log");
    }
    

提交回复
热议问题