用于免交互安装GitHub CLI、卸载以及在部署工具中检测安装状态的命令。只列出确定可用的命令:来自清单文件,或来自安装程序技术的官方默认参数。
相关教程: 静默安装参数大全:MSI、NSIS、Inno Setup · 用注册表或PowerShell卸载程序
使用winget
PowerShell
winget install --id GitHub.cli -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id GitHub.cli -e --silentwinget uninstall --id GitHub.cli -e --silent按安装包
64位 · MSI · 所有用户
静默安装
msiexec /i gh_2.103.3_windows_amd64.msi /qn /norestart输出日志
msiexec /i gh_2.103.3_windows_amd64.msi /qn /norestart /l*v "%TEMP%\github-cli-install.log"卸载
msiexec /x {8B5049E4-77C4-4637-825C-77C6C1080778} /qn /norestart- MSI产品代码
- {8B5049E4-77C4-4637-825C-77C6C1080778}
- 卸载注册表项
- HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{8B5049E4-77C4-4637-825C-77C6C1080778}
- UpgradeCode
- {8CFB9531-B959-4E1B-AA2E-4AF0FFCC4AF4}
- 安装目录
- %ProgramFiles%\GitHub CLI
64位 · ZIP
无需安装(绿色版)
ARM64 · MSI · 所有用户
静默安装
msiexec /i gh_2.103.3_windows_arm64.msi /qn /norestart输出日志
msiexec /i gh_2.103.3_windows_arm64.msi /qn /norestart /l*v "%TEMP%\github-cli-install.log"卸载
msiexec /x {356C78A3-D8F8-486A-B686-217AFBC67511} /qn /norestart- MSI产品代码
- {356C78A3-D8F8-486A-B686-217AFBC67511}
- 卸载注册表项
- HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{356C78A3-D8F8-486A-B686-217AFBC67511}
- UpgradeCode
- {5D15E95C-F979-41B0-826C-C33C8CB5A7EB}
- 安装目录
- %ProgramFiles%\GitHub CLI
ARM64 · ZIP
无需安装(绿色版)
32位 · MSI · 所有用户
静默安装
msiexec /i gh_2.103.3_windows_386.msi /qn /norestart输出日志
msiexec /i gh_2.103.3_windows_386.msi /qn /norestart /l*v "%TEMP%\github-cli-install.log"卸载
msiexec /x {2643C99A-0858-411A-BD5A-BBF06DC0EF78} /qn /norestart- MSI产品代码
- {2643C99A-0858-411A-BD5A-BBF06DC0EF78}
- 卸载注册表项
- HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{2643C99A-0858-411A-BD5A-BBF06DC0EF78}
- UpgradeCode
- {767EC5D2-C8F0-4912-9901-45E21F59A284}
- 安装目录
- %ProgramFiles(x86)%\GitHub CLI
32位 · ZIP
无需安装(绿色版)
PowerShell:下载、校验、安装
下载官方文件,校验SHA256后静默安装。
install-github-cli.ps1
$url = 'https://github.com/cli/cli/releases/download/v2.103.3/gh_2.103.3_windows_amd64.msi'
$sha256 = '5073112B7ABB5FFBBA24B76AEE7E89269AF531218C0A42751F5F0BFB6440C2CC'
$file = Join-Path $env:TEMP 'gh_2.103.3_windows_amd64.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait install-github-cli.ps1
$url = 'https://github.com/cli/cli/releases/download/v2.103.3/gh_2.103.3_windows_arm64.msi'
$sha256 = '751F6CD2DAFFF9340822BF10C910F6DAEC3896638C030FCC8DDA8822129E4780'
$file = Join-Path $env:TEMP 'gh_2.103.3_windows_arm64.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait install-github-cli.ps1
$url = 'https://github.com/cli/cli/releases/download/v2.103.3/gh_2.103.3_windows_386.msi'
$sha256 = 'B98702030EF20FA21F17675A8D67C4343C284C69AC6D42C418806999B80C7FE5'
$file = Join-Path $env:TEMP 'gh_2.103.3_windows_386.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait