Skip to content

Instantly share code, notes, and snippets.

@altrive
Last active March 29, 2024 14:27
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save altrive/5316967 to your computer and use it in GitHub Desktop.
Save altrive/5316967 to your computer and use it in GitHub Desktop.
Unattend install script for Visual Studio 2012 and Visual Studio 2012 Update 2

1.Download Visual Studio 2012 WebInstaller

Visual Studio 2012 http://www.microsoft.com/visualstudio/eng/downloads Visual Studio 2012 Update 2 http://www.microsoft.com/en-us/download/details.aspx?id=38188

  1. Download offline install image

Run following command to extract offline install image. and copy files to network share.

vs_professional.exe /layout "C:\Temp\VS2012Pro" /Passive /Log %Temp%\VS2012_Extract.log
VS2012.2.exe /layout "C:\Temp\VS2012_Update2" /Passive /Log %Temp%\VS2012Update2_Extract.log
  1. Install

Run following command to install packages.

$sw = [Diagnostics.Stopwatch]::StartNew()
Install-VisualStudio -ImagePath "\\172.16.0.1\Shared\Images\VS2012Pro" -InstallPath $null -ProductKey $null
Write-Host ("Install Visual Studio 2012 : Elapsed {0} [minutes]." -f $sw.Elapsed.TotalMinutes)

$sw.Restart()
Install-VisualStudioUpdate -ImagePath "\\172.16.0.1\Shared\Images\VS2012_Update2" 
Write-Host ("Install Visual Studio 2012 Update2 : Elapsed {0} [minutes]." -f $sw.Elapsed.TotalMinutes)

Note: The local path name should not exceed 70 characters, and the network path name should not exceed 39 characters http://msdn.microsoft.com/en-us/library/vstudio/ee225237.aspx

function Install-VisualStudio
{
[CmdletBinding()]
param (
[string] $ImagePath,
[string[]] $ArgumentList,
[string] $InstallPath,
[string] $ProductKey
)
Write-Verbose "Install Visual Studio 2012..."
$filePath = Join-Path $ImagePath "vs_*.exe" -Resolve
$argumentList = @("/Full","/Passive","/NoRestart","/Log $env:Temp\VisualStudio2012_Install.log")
if(![String]::IsNullOrEmpty($InstallPath))
{
$argumentList +='/CustomInstallPath "$InstallPath"'
}
if(![String]::IsNullOrEmpty($ProductKey))
{
$argumentList +='/ProductKey $ProductKey'
}
Write-Progress -Activity "Install Visual Studio 2012" -Status "Install..."
Start-Process -FilePath $filePath -ArgumentList $ArgumentList -WorkingDirectory $env:Temp -Wait
Write-Progress -Activity "Install Visual Studio 2012" -Completed
}
function Install-VisualStudioUpdate
{
[CmdletBinding()]
param (
[string] $ImagePath
)
Write-Verbose "Install Visual Studio 2012 Update..."
$filePath = Join-Path $ImagePath "VS2012.*.exe" -Resolve
$argumentList = @("/Full","/Passive","/NoRestart","/NoWeb","/Log $env:Temp\VisualStudio2012_Update_Install.log")
Write-Progress -Activity "Install Visual Studio 2012 Update" -Status "Install..."
Start-Process -FilePath $filePath -ArgumentList $ArgumentList -WorkingDirectory $env:Temp -Wait
Write-Progress -Activity "Install Visual Studio 2012 Update" -Completed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment