Question

I'm trying to install both the 32-bit and the 64-bit versions of Visual Studio 2005 as part of a Powershell script on our Win2008 instances. When I try to invoke the installation of both EXE files without a break, the second EXE (x86) doesn't execute since the x64 one hasn't finished installing.

So, I added a 5 sec sleep after each invoke and that seems to work now. However, I'm not very happy with this solution as it looks more like a workaround than a proper way to handle the task at hand.

Is there a better way to do this - maybe enqueue the files for install - so they execute one after another?

Here are the specific lines of code:

 if ($OSArchitecture -eq "64-bit")
    {  Write-Output "Found 64-bit OS. Installing both VC++ files for compat"
       start-process .\vcredist_x64.exe /Q
       start-sleep 5
       start-process .\vcredist_x86.exe /Q    
       start-sleep 5
    }
Was it helpful?

Solution

You must use the Start-Process -Wait parameter.

-Wait Waits for the specified process to complete before accepting more input. This parameter suppresses the command prompt or retains the window until the process completes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top