How to Install Visual Studio Code Silently for All Users with PowerShell
Windows Server 2022 has no winget, but VS Code’s own installer takes switches that install it for every account without showing a window.

On this page
TL;DR
In an elevated PowerShell session:
$installer = Join-Path $env:TEMP 'VSCodeSetup-x64.exe'
Invoke-WebRequest -OutFile $installer `
-Uri 'https://code.visualstudio.com/sha/download?build=stable&os=win32-x64'
Start-Process -FilePath $installer -Wait `
-ArgumentList '/VERYSILENT', '/NORESTART', '/MERGETASKS=!runcode,addtopath'
Remove-Item $installer/VERYSILENT shows nothing, /NORESTART never reboots, !runcode stops the
installer opening VS Code when it finishes, and addtopath puts code on the
system PATH for the next sign-in.
On a machine that has winget, winget install Microsoft.VisualStudioCode --scope machine --silent
does this job with less to know. Windows Server 2022 doesn’t ship winget.
VS Code’s Windows installer is an Inno
Setup package, and Inno Setup has had stable command-line switches for
decades. The whole job is fetching the right build, running it with those
switches, and knowing which of its optional tasks to turn on or off.
Download the system installer
$installer = Join-Path $env:TEMP 'VSCodeSetup-x64.exe'
Invoke-WebRequest -OutFile $installer `
-Uri 'https://code.visualstudio.com/sha/download?build=stable&os=win32-x64'That URL is Microsoft’s documented direct-download link for the current stable
system installer, which puts VS Code under Program Files for every
account on the machine. Change os=win32-x64 to os=win32-x64-user for the
per-user installer, which needs no elevation and installs under one account’s
%LocalAppData%. For a server or a shared workstation the system build is the
one you want.
On Windows PowerShell 5.1 the download is faster with the progress bar off:
$ProgressPreference = 'SilentlyContinue'Run it without a window
Start-Process -FilePath $installer -Wait `
-ArgumentList '/VERYSILENT', '/NORESTART', '/MERGETASKS=!runcode,addtopath'Inno Setup reads its switches before it draws anything, so /VERYSILENT with
/NORESTART is a complete unattended install with no answer file. -Wait
matters. Without it the script moves on while the installer is still
running, and anything after — a settings file, an extension install — races
it.
The switches:
| Switch | Effect |
|---|---|
/VERYSILENT | No wizard, no progress window. /SILENT shows progress only. |
/NORESTART | Never reboot, even when the installer requests one. |
/MERGETASKS=… | Turn the optional tasks on or off; a leading ! turns one off. |
The installer offers six tasks. After install, runcode launches the editor,
addtopath edits PATH, and associatewithfiles registers Code as an editor
for supported file types. The other three, desktopicon,
addcontextmenufiles and addcontextmenufolders, add the shortcut and the
“Open with Code” entries in Explorer. On a headless install runcode leaves an
editor window nobody will ever see, and it is on by default, so turn it off.
Turning runcode off leaves every other task as it was, because /MERGETASKS
applies your changes on top of the installer’s defaults. The /TASKS switch
would replace them wholesale.
Verify
Remove-Item $installer
Test-Path "$env:ProgramFiles\Microsoft VS Code\Code.exe"
& "$env:ProgramFiles\Microsoft VS Code\bin\code.cmd" --versionThe version check calls the launcher by path because the PATH change from
addtopath is not visible in the session that ran the installer.
Expected result
Code.exe exists under Program Files\Microsoft VS Code, the uninstall entry
reports the version you expected, and code --version works in a new shell.
A new one, because addtopath edits the machine PATH and the session that ran
the installer still has the old one.
Common failures
Script hangs at Start-Process
The installer is showing a dialog you can’t see. Usually VS Code is already
running under this account and Inno Setup is asking whether to close it. Stop
Code.exe first, or add /CLOSEAPPLICATIONS.
Access denied under Program Files
The session isn’t elevated. The system installer needs it; the user installer doesn’t.
code isn’t recognized after the install
Either addtopath wasn’t in /MERGETASKS, or you’re in the same shell that
ran the installer. Open a new one. On Windows Server the change reaches
services and scheduled tasks only after they restart.
Download is a few kilobytes of HTML
The download URL redirected to an error page, from a proxy or an outbound rule blocking the CDN. Check the signature before running it:
Get-AuthenticodeSignature $installer | Select-Object Status, SignerCertificateThe real installer reports Valid, signed by Microsoft Corporation. Anything
else means the file isn’t the installer; don’t run it.
Tested with
- OS
- Windows Server 2019 (10.0.17763)
- PowerShell
- Windows PowerShell 5.1
- VS Code
- 1.139.0 upgraded to 1.140.0
- Installer
- system, Inno Setup
- Date
- October 2026