Install Visual C++ Redistributables 2005 while setup install

297 Views Asked by At

I still need to install the Microsoft C++ 2005 Redistributables during the installation process of my Windows service (Visual Studio Setup project). I already have programming that installs these packages in the background. This programming works. Now I want to call this programming when the Windows service is installed. But then I always get the error message "Another program is being installed please wait until the installation is complete and then try installing the software again.". I have already tried all methods of the ProjectInstaller class (OnBeforeInstall, OnAfterInstall, Commit) - nothing works. But in the default prerequisites I can't select this package because it is too old.

How can I solve this?

Thank you very much! :)

1

There are 1 best solutions below

2
On BEST ANSWER

You can follow these steps to install Microsoft C++ 2005 Redistributables when setup install:

  1. Follow this document to create a custom action for your setup project.
  2. Add these codes in install method
    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);

        Process myProcess = new Process();

        myProcess.StartInfo.FileName = @"{Your Directory}\vcredist_x86.EXE";

        myProcess.StartInfo.Arguments = "/Q";      //install automactically

        myProcess.StartInfo.CreateNoWindow = true;

        myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

        myProcess.StartInfo.Verb = "runas";        //run exe as administrator(Important!)

        myProcess.Start();
    }