用于免交互安装Microsoft Visual Studio Code、卸载以及在部署工具中检测安装状态的命令。只列出确定可用的命令:来自清单文件,或来自安装程序技术的官方默认参数。
相关教程: 静默安装参数大全:MSI、NSIS、Inno Setup · 用注册表或PowerShell卸载程序
使用winget
PowerShell
winget install --id Microsoft.VisualStudioCode -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id Microsoft.VisualStudioCode -e --silentwinget uninstall --id Microsoft.VisualStudioCode -e --silent按安装包
64位 · EXE(Inno Setup) · 仅当前用户 · en-US
静默安装
VSCodeUserSetup-x64-1.146.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-自定义安装目录
VSCodeUserSetup-x64-1.146.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /DIR="C:\Apps\microsoft-visual-studio-code"64位 · EXE(Inno Setup) · 所有用户 · en-US
静默安装
VSCodeSetup-x64-1.146.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-自定义安装目录
VSCodeSetup-x64-1.146.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /DIR="C:\Apps\microsoft-visual-studio-code"ARM64 · EXE(Inno Setup) · 仅当前用户 · en-US
静默安装
VSCodeUserSetup-arm64-1.146.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-自定义安装目录
VSCodeUserSetup-arm64-1.146.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /DIR="C:\Apps\microsoft-visual-studio-code"ARM64 · EXE(Inno Setup) · 所有用户 · en-US
静默安装
VSCodeSetup-arm64-1.146.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-自定义安装目录
VSCodeSetup-arm64-1.146.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /DIR="C:\Apps\microsoft-visual-studio-code"PowerShell:下载、校验、安装
下载官方文件,校验SHA256后静默安装。
install-microsoft-visual-studio-code.ps1
$url = 'https://vscode.download.prss.microsoft.com/dbazure/download/stable/69047191fc427f2f92828279aae1d90d8eeda7ab/VSCodeUserSetup-x64-1.146.0.exe'
$sha256 = 'DA5AAD5FD88244FFC35D5F6C86C5214F9CEED6520888E4C5CCF3E8678E5BBF0A'
$file = Join-Path $env:TEMP 'VSCodeUserSetup-x64-1.146.0.exe'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process -FilePath $file -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' -Wait install-microsoft-visual-studio-code.ps1
$url = 'https://vscode.download.prss.microsoft.com/dbazure/download/stable/69047191fc427f2f92828279aae1d90d8eeda7ab/VSCodeSetup-x64-1.146.0.exe'
$sha256 = '972FCB16D819532A25AF8DC1976E1C80508E080BF56EB65BFD6A35EED983A35B'
$file = Join-Path $env:TEMP 'VSCodeSetup-x64-1.146.0.exe'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process -FilePath $file -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' -Wait install-microsoft-visual-studio-code.ps1
$url = 'https://vscode.download.prss.microsoft.com/dbazure/download/stable/69047191fc427f2f92828279aae1d90d8eeda7ab/VSCodeUserSetup-arm64-1.146.0.exe'
$sha256 = 'F4B8A50821C0E11604B7A63C17FE8CE413FC7C872291927E5B82BEF18E5B28BA'
$file = Join-Path $env:TEMP 'VSCodeUserSetup-arm64-1.146.0.exe'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process -FilePath $file -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' -Wait install-microsoft-visual-studio-code.ps1
$url = 'https://vscode.download.prss.microsoft.com/dbazure/download/stable/69047191fc427f2f92828279aae1d90d8eeda7ab/VSCodeSetup-arm64-1.146.0.exe'
$sha256 = '533E1EC692275354EF98A63C659F55BE3C3CA84586A0BAE2A6B678A6FC48A2C4'
$file = Join-Path $env:TEMP 'VSCodeSetup-arm64-1.146.0.exe'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process -FilePath $file -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' -Wait