To create a package deployment for Visual Studio Code (VS Code) with Auto Update disabled you must do the following.
- Install the version of Visual Studio Code you plan to deploy.
- Browse to: C:\Program Files\Microsoft VS Code\resources\app
- Open the “product.json” file and remove the following line:
“updateUrl”: “https://update.code.visualstudio.com”, - Save the “product.json” file to the location of your deployment and write the following script to deploy it.
It’s important to note that this “product.json” file changes with every version. So I do not recommend re-using this file. Until there is another way to automatically disable Auto Update, this is what I found as the best solution.
# Script: Install-VSCode.ps1
# Description: Installs VSCode
# Execution: PS> PowerShell.exe -ExecutionPolicy ByPass ".\Install-VSCode.ps1" -Wait -WindowStyle Hidden
# Author: Harry Caskey (harrycaskey@gmail.com)
#
# Gather Installer Path Information
$VSCodeInstaller = (Resolve-Path "*VSCodeSetup*").Path
# Gather Setup Instructions Path Information, if you have a setupconfig file, this will install with that configuration.
$VSCodeSetupConfig = (Resolve-Path "*vscode-setupconfig*").Path
# Gather Configuration Path Information
$VSCodeSetting = (Resolve-Path "*product.json*").Path
# Stop VS Code Process
Get-Process -Name "*Code*" | Stop-Process -Force -ErrorAction Ignore
# If installed, uninstall the current version.
if (Test-Path "$env:SystemDrive\Program Files\Microsoft VS Code\unins000.exe") {Start-Process "$env:SystemDrive\Program Files\Microsoft VS Code\unins000.exe" -ArgumentList "/VERYSILENT" -WindowStyle Hidden -Wait}
# Remove Public Shortcut
if (Test-Path "$env:SystemDrive\Users\Public\Desktop\Visual Studio Code.lnk") {Remove-Item "$env:SystemDrive\Users\Public\Desktop\Visual Studio Code.lnk" -Force}
# Remove Start Menu Shortcut
if (Test-Path "$env:SystemDrive\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio Code.lnk") {Remove-Item "$env:SystemDrive\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio Code.lnk" -Force}
# Stop VS Code Process
Get-Process -Name "*Code*" | Stop-Process -Force -ErrorAction Ignore
# Execute Installer Command
Start-Process "$VSCodeInstaller" -ArgumentList "/VERYSILENT /NORESTART /LOADINF=`"$VSCodeSetupConfig`" /SUPRESSMSGBOXES /CLOSEAPPLICATIONS /MERGETASKS=!runcode" -WindowStyle Hidden -Wait
# VSCode Installer Path
$VSCodePath = "$env:SystemDrive\Program Files\Microsoft VS Code\resources\app"
# Copy Configuration File that Disables Auto Update
(Copy-Item "$VSCodeSetting" -Destination "$VSCodePath" -Force)
# Remove Public Shortcut (If Desired)
if (Test-Path "$env:SystemDrive\Users\Public\Desktop\Visual Studio Code.lnk") {Remove-Item "$env:SystemDrive\Users\Public\Desktop\Visual Studio Code.lnk" -Force}
# If you use Endpoint Manager/ConfigMgr/SCCM the following commands will execute the machine retrival, application and hardware inventory policies.
# Machine Policy Retrieval Cycle
Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" -ErrorAction Ignore
# Machine Policy Evaluation Cycle
Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" -ErrorAction Ignore
# Application Deployment Evaluation Cycle
Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}" -ErrorAction Ignore
# Hardware Inventory Cycle
Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}" -ErrorAction Ignore
# Verify Installer
if (Test-Path -Path "C:\Program Files\Microsoft VS Code\Code.exe") {$vsCodeInstalled = $true} else {$vsCodeInstalled = $false}
if ($vsCodeInstalled) {$vsCodeVersion = ([System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Program Files\Microsoft VS Code\Code.exe")).FileVersion} else {exit(1)}
# This script is for returning $true, if you are upgrading from a previous version. This will check to make sure the file version is what you deployed.
if ("1.40.2" -ge $vsCodeVersion) {$vsCodeUpdated = $true} else {$vsCodeUpdated = $false}
# Test if Installed
if ($vsCodeInstalled -and $vsCodeUpdated) {exit(0)} else {exit(1)}
After you’ve deployed the application via-script you will no longer see the update option when opening Visual Studio Code.
One Reply to “Disable Auto Update with Visual Studio Code”
Instead of deploying VS Code first and then taking a copy of the product.json file and then replacing after the install you could simply remove the updateurl object in the json using powershell after the actual install.
$productJson = Get-Content ‘C:\Program Files\Microsoft VS Code\resources\app\product.json’ -raw | ConvertFrom-Json
$productJson.PsObject.Properties.Remove(‘updateUrl’)
$productJson | ConvertTo-Json -depth 32| set-content ‘C:\Program Files\Microsoft VS Code\resources\app\product.json’