无提示MSI卸载不要删除安装文件夹

时间:2012-09-22 11:28:59

标签: c# .net visual-studio-2010 installer

我使用visual studio msi安装程序创建了一个空项目。在安装时,它只是为项目创建文件夹和exe文件。

但是当我尝试静默卸载时,它会从程序列表中删除安装,但它会离开文件夹。我也需要删除该文件夹,并希望这样做而不必在代码中手动删除它。

   // This is how to uninstall a basic msi app

        // Create the uninstall process.
        Process proc = new Process();

        // Define the parameters for the process
        proc.StartInfo.FileName = "msiexec.exe";

        // This is the Product Code from your Basic MSI InstallShield Project

        proc.StartInfo.Arguments = "/x" + " " + ProductCode + " " + "/qn";

        // Start the process.
        proc.Start();

        // Wait for the uninstall process to end.
        proc.WaitForInputIdle();
        proc.WaitForExit();

        // Release resources.
        proc.Close();

1 个答案:

答案 0 :(得分:0)

指示MSI使用msiexec的{​​{3}}命令行选项输出日志文件。它应该告诉您为什么卸载程序无法删除安装文件。可能的原因包括文件夹被锁定(需要重新启动才能删除)或文件夹上的文件权限以防止删除。有关详细信息,请参阅/L logfile.txtWix installer could not remove installation folder