Skip to content

UNT-CAS/Update-VSCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

VS Code doesn't do completely silent updates. This works around that shortcoming and allows the user to just use VS Code.

Description

This is a simple implementation of a more complex installer/updater process that I manage for work. I expect this script to be implemented as a scheduled task; either manually or via GPO.

Quick Start

See the Base64 Example, below.

Parameters

Parameters let you customize some installer options. All parameters can also be set with an environment variable as such: UpdateVSCode${Parameter}. For example, the SetupSilent variable as an environment variable would be: UpdateVSCodeSetupSilent.

Keep in mind that environment variables are always strings. So, setting a switch parameter to '$false' via an environment variable would still be $true. You can see what I mean with these examples: [bool]'true', [bool]'false', [bool]'$true', [bool]'$false', [bool]'0', and [bool]''.

DoNotBlock

  • Type: [switch]

Set this if you don't want to have VS Code blocked from executing during the installation/upgrade of VS Code. I'm not sure what the implications of this are, but I do know that VS Code's setup.exe checks for VS Code to be running and doesn't let the installer proceed if it is. I also realize the VS Code can install in the background if you initiate the install from withing VS Code.

LogPath

  • Type: [IO.FileInfo]
  • Default: "${env:SystemRoot}\Logs\Update-VSCode.ps1.log"

This is the full path (directory and name) of the log file. Additionally, the setup.exe will use this to generate its log file's full path by appending -Setup before the extension; such as: "${env:SystemRoot}\Logs\Update-VSCode.ps1-Setup.log".

Only the latest iteration of the log file is kept. In other words: the logging will not append to the previous run of this script. This keeps the log file from getting bloated. I tend to believe that only the latest iteration is ever really needed anyway.

PopupTitle

  • Type: [string]
  • Default: 'VS Code: Installing/Upgrading'

When blocking VS Code from launching during an install/upgrade, there will be a message box that pops up if someone attempts to launch VS Code. This sets the title of that message box.

PopupText

  • Type: [string]
  • Default: 'VS Code is currently being installed or upgraded. It will not be accessible for the duration of the install. This won''t take long ... try again in a minute.'

When blocking VS Code from launching during an install/upgrade, there will be a message box that pops up if someone attempts to launch VS Code. This sets the body text of that message box.

PopupDuration

  • Type: [int]
  • Default: 30

When blocking VS Code from launching during an install/upgrade, there will be a message box that pops up if someone attempts to launch VS Code. This sets the auto-close timeout in seconds of that message box.

PopupType

  • Type: [int32]
  • Default: 0x30

When blocking VS Code from launching during an install/upgrade, there will be a message box that pops up if someone attempts to launch VS Code. This sets the alert icon of that message box.

SetupMergeTasks

  • Type: [string]
  • Default: 'addcontextmenufiles,addcontextmenufolders,addtopath,associatewithfiles,!desktopicon,!quicklaunchicon,!runcode'

This setting allows you to customize some of the installer options/tasks. The tasks listed as default, above, are the current tasks in the code.iss file, thanks StackOverflow. Think of each task as a checkbox. Putting a bang (!) in front of the taskname is like unchecking the box.

These tasks are subject to change. Check the latest version of that code.iss file for details; it will definitely be more updated than this README.

SetupSilent

  • Type: [switch]

If set, the setup.exe will be passed the /SILENT parameter, instead of using this script's default /VERYSILENT parameter.

If you specify this switch and the SetupSilentNoCancel switch, the SetupSilentNoCancel switch will take precedence.

SetupSilentNoCancel

  • Type: [switch]

If set, the setup.exe will be passed the /SILENT and /NOCANCEL parameters, instead of using this script's default /VERYSILENT parameter.

If you specify this switch and the SetupSilent switch, this switch will take precedence.

Examples

The script file is not needed on the computer. I just created a scheduled task to run this as the System user. You have at least two options to accomplish this:

  1. Base64 encode it and run it with the powershell.exe -EncodedCommand parameter. (Personal Preference)
  2. Download and Execute it straight from GitHub, I'm sure GitHub won't mind. 😏

There is while loop in this script that could potentially run forever. Use the scheduled task settings to create a timeout.

Both options are below ...

Base64 Encoded

This is my personal preference because there's really no reason to download the code base constantly.

$url = 'https://raw.githubusercontent.com/UNT-CAS/Update-VSCode/master/Update-VSCode.ps1'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$command = Invoke-WebRequest -Uri $url -UseBasicParsing
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$encodedCommand = [Convert]::ToBase64String($bytes)

Then use the contents of $encodedCommand like this:

powershell.exe -W H -Ex B -NoP -NonI -EncodedCommand "WwBEAGkAYQBnAG4AbwBzAHQAaQBjAHMALgBQAHIAbwBjAGUAcwBzAF0AOgA6AFMAdABhAHIAdAAoACcAaAB0AHQAcABzADoALwAvAHUAbgB0AGMAYQBzAC4AcABhAGcAZQAuAGwAaQBuAGsALwBMADgAdABjACcAKQA="

Note: you might want to re-base64 it yourself. It is not the base64 you are looking for.

Download and Execute

❗️ Seriously, don't do it this way unless you point it at a commit id, or you fork this repo and point it at your fork.

powershell.exe -W H -Ex B -NoP -NonI "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest 'https://raw.githubusercontent.com/UNT-CAS/Update-VSCode/e00b0c8c25a66d07361148a6573c47810be8c63a/Update-VSCode.ps1' -UseBasicParsing | Invoke-Expression"

Note: you might want to confirm that the commit id in that URL is the id you want. I likely won't come back and update the commit id every time I make a change to the code.

About

Automagically update VS Code so you don't have to worry about it anymore.

Resources

Stars

Watchers

Forks

Packages

No packages published