0

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! :)

大陸北方網友
  • 3,696
  • 3
  • 12
  • 37
nicetomitja
  • 145
  • 10
  • In a hurry, a few links: [About Visual Studio C++ runtime](https://stackoverflow.com/a/67375780/129130). In VS: Right click main setup project, select Properties => [Prerequisites](https://learn.microsoft.com/en-us/visualstudio/ide/reference/prerequisites-dialog-box?view=vs-2017). [Adding Custom prerequsites to setup project](https://stackoverflow.com/questions/1334436/adding-custom-prerequsites-to-visual-studio-setup-project), [Creating Bootstrapper Packages](https://learn.microsoft.com/nb-no/previous-versions/visualstudio/visual-studio-2015/deployment/creating-bootstrapper-packages). – Stein Åsmul May 04 '21 at 02:07

1 Answers1

0

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();
    }
Dylan
  • 504
  • 2
  • 5
  • 9
  • Another question for this. I want to install x86 and x64 Redistributables one after the other. How can i adjust these? Unfortunately, I do not know exactly when the first installation is complete and I can start with the second. Is there a trick? – nicetomitja May 09 '21 at 06:08
  • You can create a new action to install x64 package – Dylan May 11 '21 at 08:03