Skip to content

Instantly share code, notes, and snippets.

@ChrisKader
ChrisKader / Readme.md
Last active November 8, 2022 04:52
Update PATH Environment Variable to include VS Codes CLI shortcuts

If you did not have the VS Code (Insiders) installer update your path (or you where not prompted due to installing via a package manager like winget), then you can use the below code to fix that.

This will update your systems PATH environment variable to include code or code-insiders.

  1. Execute the code below from within a VS Code (Insiders) PowerShell prompt.
  2. The script will output the code you then need to copy, paste and execute in a PowerShell CLI with elevated privilges.
switch((Test-Path "$Env:VSCODE_GIT_ASKPASS_NODE") -and ($Env:Path -split ';' -contains "$(Split-Path $Env:VSCODE_GIT_ASKPASS_NODE)\bin")) {$true{$codePath=Split-Path $Env:VSCODE_GIT_ASKPASS_NODE;Write-Host -ForegroundColor Green "`nExecute the below command (yellow text) from an PowerShell prompt with ELEVATED privileges`n"; Write-Host -ForegroundColor Yellow "`$Env:Path;[Environment]::SetEnvironmentVariable(`"Path`", `$Env:Path + `";$codePath\bin`", `"Machine`");`$Env:Path`n"} $false {Write-Host -ForegroundColor Red '