Vcreds - Powershell
Hi, Couple of things. I have to install the pre req's as part of my powershell script. When I try install vcreds via powershell with the recommended switches it does not go silent. Also I would like a pause between each running. Looking on the internet -wait or start-sleep is suggested. -wait doesn't appear to work in this instance.
#Installs VCreds
Start-Process "\\Share\rollout\Installations\Scripts\Files\Confirm\2010\vcredist_x86.exe" /passive | Out-Null
Start-Process "\\Share\rollout\Installations\Scripts\Files\Confirm\2010\vcredist_x64.exe" /passive | Out-Null
Start-Process "\\Share\rollout\Installations\Scripts\Files\Confirm\2012Update4\vcredist_x86.exe" /passive | Out-Null
Start-Process "\\Share\rollout\Installations\Scripts\Files\Confirm\2012Update4\vcredist_x64.exe" /passive | Out-Null
Any advice is appreciated
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
rad33k
7 years ago
As VBScab mentioned it is good to have vcredists added to the core image.
Here are my comments regarding the script:
- Vcredist executable started with /q parameter does not display anything (/passive displays a progress dialog)
-Wait parameter of the Start-Process command is self-explanatory - scripts waits for the command to be completed and then moves to the next line (starts the process synchronously). It does not work if EXE just starts some sub processes and ends before sub processes are finished, but as I remember it is not the case for vcredists executable.
-WindowStyle Hidden - hides the main GUI of the called EXE (It does not hide additional pop-ups started as sub processes etc.)
If you need additional pause between each execution you can use mentioned Start-Sleep (a.k.a. Sleep) cmdlet.
You may also consider some error handling, for example:
Here are my comments regarding the script:
- Vcredist executable started with /q parameter does not display anything (/passive displays a progress dialog)
-Wait parameter of the Start-Process command is self-explanatory - scripts waits for the command to be completed and then moves to the next line (starts the process synchronously). It does not work if EXE just starts some sub processes and ends before sub processes are finished, but as I remember it is not the case for vcredists executable.
-WindowStyle Hidden - hides the main GUI of the called EXE (It does not hide additional pop-ups started as sub processes etc.)
If you need additional pause between each execution you can use mentioned Start-Sleep (a.k.a. Sleep) cmdlet.
You may also consider some error handling, for example:
$Proc = Start-Process -FilePath "\\Share\rollout\Installations\Scripts\Files\Confirm\2010\vcredist_x86.exe" -ArgumentList "/q /norestart" -Wait -WindowStyle Hidden -PassThruEDIT: *I forgot about -PassThru attribute :)
If (($Proc.ExitCode -eq 0) -or ($Proc.ExitCode -eq 3010)){
#Success
#Do Something
}
else{
#Fail
#Do something else
}
#Pause script for 2 seconds
Start-Sleep -S 2
....