How do I update VScode

Whenever I see a twitter post from @code saying
, I know it’s time to update my local copy of VSCode 😀

So, I open my (saved) code snippet and run the following
Disclaimer: use at your own risk, it’s not a function or a module. I only need some level of automation but not full automation 😛

if (-not(Test-Path ~/Downloads/VSCode -PathType Container)) {
Write-Warning 'Folder ~/Downloads/VSCode not found'
if (Test-Path ~/Downloads/VSCode/ {
Write-Warning -Message 'Zip file found in ~/Downloads/VSCode/'
# version in prod
$localver = (Get-Item -Path 'C:\Program Files (x86)\Microsoft VS Code\Code.exe' -ErrorAction SilentlyContinue).VersionInfo.FileVersion
Write-Verbose -Message "Local version in program files $($localver) detected" -Verbose
# new online version
$uri = ''
$onlineloc = (Invoke-WebRequest -Uri $uri -MaximumRedirection 0 -ErrorAction SilentlyContinue -UseBasicParsing).Headers.Location
Write-Verbose -Message "Online location found at $($onlineloc)" -Verbose
$onlinever =([regex]'VSCode-win32-(ia32-)?(?<Version>(\d{1,}\.){1,3}\d{1,})\.zip').Matches(
if ([version]$localver -eq [version]$onlinever) {
Write-Verbose -Message "Already up-to-date: $($localver)" -Verbose
} else {
Write-Verbose -Message "You need to update your local version $($localver) to $($onlinever)" -Verbose
Write-Verbose "About to download online version $($onlinever)" -Verbose
Invoke-WebRequest -Uri $onlineloc -OutFile ~/Downloads/VSCode/
if (Test-Path ~/Downloads/VSCode/ {
# rename folder
if (Test-Path ~/Downloads/VSCode/VSCode-win32-stable) {
Rename-Item -Path ~/Downloads/VSCode/VSCode-win32-stable -NewName ('VSCode-win32-stable-{0}' -f (
dir "~/Downloads/VSCode/VSCode-win32-stable/Code.exe").VersionInfo.FileVersion
) -Verbose
# expand zip
Expand-Archive -Path ~/Downloads/VSCode/ -DestinationPath ~/Downloads/VSCode/VSCode-win32-stable -Force
# new version?
(Get-Item -Path '~/Downloads/VSCode/VSCode-win32-stable/Code.exe').VersionInfo |
Select FileVersion,ProductVersion
# signed?
dir '~\Downloads\VSCode\VSCode-win32-stable\*' -Include *.exe,*.dll -Recurse -Force -ErrorAction SilentlyContinue|
# push to prod
& (gcm "$($env:systemroot)\system32\robocopy.exe") @(
'C:\Program Files (x86)\Microsoft VS Code','/R:0','/Z','/S','/PURGE','/NP'
# ren zip
Rename-Item -Path ~/Downloads\VSCode\ -NewName ('VSCode-win32-stable-{0}.zip' -f (
dir "~/Downloads/VSCode/VSCode-win32-stable/code.exe").VersionInfo.FileVersion
) -Verbose
# enjoy!
& 'C:\Program Files (x86)\Microsoft VS Code\Code.exe'

1 thought on “How do I update VScode

  1. Pingback: Dew Drop - July 13, 2017 (#2519) - Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.