diff --git a/Get-Bootcamp.ps1 b/Get-Bootcamp.ps1 index 3fb6b76..a0e7a78 100644 --- a/Get-Bootcamp.ps1 +++ b/Get-Bootcamp.ps1 @@ -17,11 +17,12 @@ if (!(Test-Path $OutputDir)) { New-Item -Path $OutputDir -ItemType Directory -Fo # Check if at least 7zip 15.14 is installed. If not, download and install it. $7z = "$env:ProgramFiles\7-Zip\7z.exe" +$7zDownload = Join-Path $env:Temp $SEVENZIP_URL.Split('/')[-1] if (Test-Path $7z) { $7zInstalled = $true } if ([version](Get-ItemProperty $7z).VersionInfo.FileVersion -lt 15.14) { Write-Host "7-Zip not installed, will install and remove." - Invoke-WebRequest -Uri $SEVENZIP_URL -OutFile "$env:Temp\$($SEVENZIP_URL.Split('/')[-1])" -ErrorAction Stop - Start-Process -FilePath $env:SystemRoot\System32\msiexec.exe -ArgumentList "/i $OutputDir\$($SEVENZIP_URL.Split('/')[-1]) /qb- /norestart" -Wait -Verbose + Invoke-WebRequest -Uri $SEVENZIP_URL -OutFile $7zDownload -ErrorAction Stop + Start-Process -FilePath $env:SystemRoot\System32\msiexec.exe -ArgumentList "/i $7zDownload /qb- /norestart" -Wait -Verbose } Write-Host "Using model: $Model" @@ -91,7 +92,11 @@ if (-not (Test-Path -PathType Container $landingDir)) {mkdir $landingDir > $null & $7z -o"$landingDir" -y x "$dmgPath" # Uninstall 7zip if we installed it -if ($7zInstalled -ne $true) { Start-Process -FilePath $env:SystemRoot\System32\msiexec.exe -ArgumentList "/x $env:Temp\$($SEVENZIP_URL.Split('/')[-1]) /qb- /norestart" -Wait } +if ($7zInstalled -ne $true) { + Write-Host "Removing 7-Zip..." + Start-Process -FilePath $env:SystemRoot\System32\msiexec.exe -ArgumentList "/x $7zDownload /qb- /norestart" -Wait + Remove-Item $7zDownload +} # Install Bootcamp and use MST if specified (I uploaded one that I had to use to fix the latest ESD on an iMac14,1) if ($Install) {