Last active
August 29, 2015 14:06
-
-
Save StefanScherer/fac6577c61679932330f to your computer and use it in GitHub Desktop.
Fix PowerShell exit code with Hotfix of KB2552055 to be used in packer-windows autounattend.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: Windows 7 / Windows 2008 R2 require KB2552055 hotfix | |
:: This fixes a problem with wrong exitcode 0 instead of custom exitcode in PowerShell 2.0 | |
setlocal | |
if defined ProgramFiles(x86) ( | |
set link=http://hotfixv4.microsoft.com/Windows%%207/Windows%%20Server2008%%20R2%%20SP1/sp2/Fix373932/7600/free/438167_intl_x64_zip.exe | |
set msufilename=%TEMP%\Windows6.1-KB2552055-x64.msu | |
) else ( | |
set link=http://hotfixv4.microsoft.com/Windows%%207/Windows%%20Server2008%%20R2%%20SP1/sp2/Fix373932/7600/free/438164_intl_i386_zip.exe | |
set msufilename=%TEMP%\Windows6.1-KB2552055-x86.msu | |
) | |
set zipfilename=%TEMP%\KB2552055.zip | |
echo Downloading Hotfix 2552055 | |
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%link%', '%zipfilename%')" <NUL | |
echo Extracting Hotfix 2552055 | |
powershell -Command "(New-Object -com Shell.Application).NameSpace('%TEMP%').CopyHere((New-Object -Com Shell.Application).NameSpace('%zipfilename%').items())" <NUL | |
echo Installing Hotfix 2552055 | |
wusa %msufilename% /quiet /norestart | |
echo Cleanup Hotfix temp files | |
del /Q %msufilename% | |
del /Q %zipfilename% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is able to patch PowerShell 2.0 of Windows 7 / Windows 2008 R2 to have a correct exit code needed for Vagrant 1.6 to work properly.
Incorrect error code when you run a PowerShell script at a command prompt in Windows 7 or in Windows Server 2008 R2
http://support.microsoft.com/kb/2552055
Writing this script I learned a lot: