免互動安裝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.141.2.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-自訂安裝資料夾
VSCodeUserSetup-x64-1.141.2.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /DIR="C:\Apps\microsoft-visual-studio-code"64位元 · EXE(Inno Setup) · 所有使用者 · en-US
靜默安裝
VSCodeSetup-x64-1.141.2.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-自訂安裝資料夾
VSCodeSetup-x64-1.141.2.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /DIR="C:\Apps\microsoft-visual-studio-code"ARM64 · EXE(Inno Setup) · 僅目前使用者 · en-US
靜默安裝
VSCodeUserSetup-arm64-1.141.2.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-自訂安裝資料夾
VSCodeUserSetup-arm64-1.141.2.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /DIR="C:\Apps\microsoft-visual-studio-code"ARM64 · EXE(Inno Setup) · 所有使用者 · en-US
靜默安裝
VSCodeSetup-arm64-1.141.2.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-自訂安裝資料夾
VSCodeSetup-arm64-1.141.2.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/16507d91be0dc1ce4f94c04d4d0430210b8685d9/VSCodeUserSetup-x64-1.141.2.exe'
$sha256 = '9B9E7305BC5F2D9176DFF8263BA146FC7B0D65CE1FB499271FD7746EC53D66ED'
$file = Join-Path $env:TEMP 'VSCodeUserSetup-x64-1.141.2.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/16507d91be0dc1ce4f94c04d4d0430210b8685d9/VSCodeSetup-x64-1.141.2.exe'
$sha256 = '43E9E2DF672BA5CEB500E5CA6304297183AD195A323B8D73C70C7DF2D60E333F'
$file = Join-Path $env:TEMP 'VSCodeSetup-x64-1.141.2.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/16507d91be0dc1ce4f94c04d4d0430210b8685d9/VSCodeUserSetup-arm64-1.141.2.exe'
$sha256 = '7EA3A25FA828C229DC8B79187EA3C6A35178A9243DD9AD1C1A4E6458CD60D8ED'
$file = Join-Path $env:TEMP 'VSCodeUserSetup-arm64-1.141.2.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/16507d91be0dc1ce4f94c04d4d0430210b8685d9/VSCodeSetup-arm64-1.141.2.exe'
$sha256 = '68A31F854F0D1DFF3F17DFE02ACBAD9238B1888DBD5BD344185C067B034B14FD'
$file = Join-Path $env:TEMP 'VSCodeSetup-arm64-1.141.2.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