开发者

Uninstalling a previous component before installing a new one using VS 2005 Setup Project

I have a Custom Action that should execute during the Install portion of an .msi setup. I have a previous version that was installed using InstallShield (which was overkill) and wanted to move to the simpler VS Setup Proj because I do not require all the control that an .isproj provides. However, doing a straight install with my new .msi seems to install side by side with the previous version. Here's what I have found out so far:

  1. I have my product ID
  2. I have written code that will uninstall the previous version through creating a process that uses MsiExec.exe (code will follow)
  3. Tried implementing the custom action to uninstall during setup but it seems you can only have one instance开发者_JAVA技巧 of MsiExec.exe running at a time.
  4. Have been to this post (http://stackoverflow.com/questions/197365/vs-setup-project-uninstall-other-component-on-install), which didnt help.

Custom Action code:

        //Exe used to uninstall
        string fileName = "MsiExec.exe";

        //Product ID of versions installed using InstallShield
        string productID = "{DC625BCF-5E7B-4FEF-96DD-3CDBA7FC02C1}";

        //Use /x for uninstall and use /qn to supress interface
        ProcessStartInfo startInfo = new ProcessStartInfo(fileName, string.Format("/x{0}", productID));
        startInfo.WindowStyle = ProcessWindowStyle.Normal;
        startInfo.UseShellExecute = false;

        //Start process
        Process uninstallProcess = Process.Start(startInfo);

        //Wait until uninstall is complete
        uninstallProcess.WaitForExit();

My hope is to eventually deploy my .msi via ClickOnce, so I am hoping for an option that will fit into deployment option. Currently everything is written in .NET 2.0 and VS 2005, but I do have .NET 4.0 and VS 2010 available to me if there is a new option that works.

Any help is appreciated.


I was able to install over the top of the previous install by making the product code of my setup the same as the code of the older version. Didn't dawn on me to try that because when you create a new version of the setup package, VS always prompts you to change your product code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜