Microsoft Visual Studio Code
Contents
About
Visual Studio Code is a free source-code editor. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. Visual Studio Code is free and available on Linux, macOS, and Windows.
Version 1.47.1
Obtain Package Source
Visual Studio Code is freely available for download.
Vendor Configuration for Silent Install
The vendor installer is based on the Inno Setup installer. Configuration options for installation including silent install can be found at jrsoftware.org.
The configuration file can be generated by running a manual install with switches:
VSCodeSetup-x64-1.47.1.exe /SAVEINF="<path>\config.inf"
config.inf
[Setup] Lang=english Dir=C:\Program Files\Microsoft VS Code Group=Visual Studio Code NoIcons=0 Tasks=addcontextmenufiles,addcontextmenufolders,addtopath
Deploy Info
Microsoft Visual Studio Code Microsoft Corporation C:\Program Files\Microsoft VS Code\Code.exe C:\Program Files\Microsoft VS Code\unins000.exe /VERYSILENT Visual Studio Code is a free source-code editor. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. Hive: HKEY_LOCAL_MACHINE Key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1 Value: DisplayVersion DataType: Version Data: 1.47.1 Operator: Greater than or equal to 32-bit: No SCCM Requirement: None
Deploy-Application.ps1
Please note the script contains Pre-installation logic to detect and uninstall any legacy version it encounters and logs the version number. It achieves this by searching the registry for the application as a keyword, then methodically running a test for it, ascertaining it’s Uninstall string, and calling it with the provided silent switches. If the application and version we want is already installed, the install will not proceed.
Relevant extracts from the script are as follows:
##*=============================================== ##* VARIABLE DECLARATION ##*=============================================== ## Variables: Application [string]$appVendor = 'Microsoft' [string]$appName = 'Visual Studio Code' [string]$appVersion = '1.47.1' [string]$appArch = 'x64' [string]$appLang = 'EN' [string]$appRevision = '01' [string]$appScriptVersion = '1.0.0' [string]$appScriptDate = '16/07/2020' [string]$appScriptAuthor = 'psadt.com' [string]$Parms = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" [string]$nameSearch = "*Visual Studio Code*" ##*=============================================== ##*=============================================== ##* PRE-INSTALLATION ##*=============================================== ## <Perform Pre-Installation tasks here> # Remove previous versions if exist ForEach ($regKey in $regKeyApplications) { $appVer = Get-ChildItem -Path $regKey | Get-ItemProperty | Where-Object {$_.DisplayName -like $nameSearch } | Select-Object -Property DisplayName, DisplayVersion, UninstallString ForEach ($ver in $appVer) { If ($ver.UninstallString) { $appExist = 1 $appRemove = $ver.DisplayName $oldVersion = $ver.DisplayVersion $Uninst = $ver.UninstallString If ($oldVersion -ne $appVersion) { # Uninstall Write-Log -Message "Uninstalling $appRemove $oldVersion" -LogType 'CMTrace' Write-Log -Message "Executing $Uninst $Parms" -LogType 'CMTrace' Start-Process $Uninst -ArgumentList $Parms -Wait -PassThru -NoNewWindow -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null } ElseIf ($oldVersion -eq $appVersion) { Write-Log -Message "$appRemove $appVersion is already installed." -LogType 'CMTrace' Exit-Script -ExitCode 0 } } } } If ($appExist -ne 1) {Write-Log -Message "No $appName installations detected." -LogType 'CMTrace'} ##*=============================================== ##* INSTALLATION ##*=============================================== ## <Perform Installation tasks here> Execute-Process -Path 'VSCodeSetup-x64-1.47.1.exe' -Parameters "/LOADINF=`"$dirFiles\config.inf`" $Parms" -WindowStyle Hidden ##*=============================================== ##* UNINSTALLATION ##*=============================================== # <Perform Uninstallation tasks here> # Remove any version if exist ForEach ($regKey in $regKeyApplications) { $appVer = Get-ChildItem -Path $regKey | Get-ItemProperty | Where-Object {$_.DisplayName -like $nameSearch } | Select-Object -Property DisplayName, DisplayVersion, UninstallString ForEach ($ver in $appVer) { If ($ver.UninstallString) { $appExist = 1 $appRemove = $ver.DisplayName $oldVersion = $ver.DisplayVersion $Uninst = $ver.UninstallString # Uninstall Write-Log -Message "Uninstalling $appRemove $oldVersion" -LogType 'CMTrace' Write-Log -Message "Executing $Uninst $Parms" -LogType 'CMTrace' Start-Process $Uninst -ArgumentList $Parms -Wait -PassThru -NoNewWindow -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null } } } If ($appExist -ne 1) { Write-Log -Message "No $appName installations detected." -LogType 'CMTrace' Exit-Script -ExitCode 1605 }
Manual installation
Accept EULA, click Next
Click Next
Click Next
Tick Add “Open with Code” action to Windows Explorer file context menu Tick Add “Open with Code” action to Windows Explorer directory context menu Click Next
Click Install
Monitor install and allow it to finish
Click Finish