MongoDB CLIを確認画面なしでインストール・アンインストールし、展開ツールで検出するためのコマンドです。マニフェストの記載か、インストーラー技術の既定値として確実なコマンドだけを表示しています。
関連ガイド: サイレントインストールのオプション一覧 · レジストリとPowerShellでアンインストールする方法
wingetを使う
PowerShell
winget install --id MongoDB.MongoDBCLI -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id MongoDB.MongoDBCLI -e --silentwinget uninstall --id MongoDB.MongoDBCLI -e --silentインストーラー別
64ビット · MSI · すべてのユーザー · en-US
サイレントインストール
msiexec /i mongocli_2.0.9_windows_x86_64.msi /qn /norestartログを出力
msiexec /i mongocli_2.0.9_windows_x86_64.msi /qn /norestart /l*v "%TEMP%\mongodb-cli-install.log"アンインストール
msiexec /x {65830CF4-FDD3-4A90-9A87-8BB5320C27F8} /qn /norestart- MSIプロダクトコード
- {65830CF4-FDD3-4A90-9A87-8BB5320C27F8}
- アンインストール用レジストリキー
- HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{65830CF4-FDD3-4A90-9A87-8BB5320C27F8}
- UpgradeCode
- {A995CDA5-9731-4158-910C-C8D15371DBDA}
- インストール先フォルダー
- %ProgramFiles(x86)%\MongoDB CLI
PowerShell:ダウンロード・検証・インストール
公式ファイルをダウンロードし、SHA256を検証してからサイレントインストールします。
install-mongodb-cli.ps1
$url = 'https://fastdl.mongodb.org/mongocli/mongocli_2.0.9_windows_x86_64.msi'
$sha256 = 'D076F622698CC65DA292C76F3263B249F8401AF725CB9A6CEAB028448A3FADE6'
$file = Join-Path $env:TEMP 'mongocli_2.0.9_windows_x86_64.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