パッケージ管理ソフトウェアの設定(Windows) - BYOD PC のセッティング(4)

はじめに

macOS では Homebrew というほぼデファクトスタンダードなパッケージ管理ツールがある。Windows ユーザはあまり CUI で管理するという文化はないようだが、探したところ Chocolatey というパッケージ管理システムを見つけた。ここでは、Chocolatey の設定方法を示しておく。

Chocolatey のインストール

インストールの仕方は本家の「Chocolatey Software | Installing Chocolatey」に書かれている。ここでは手順だけ箇条書きで示しておく。

  • Windows アイコンの場所で右ボタンを押して「Windows PowerShell (管理者)」を実行する。
    f:id:hkob:20200404154527p:plain
    PowerShellを管理者として実行
  • 権限の確認が出るので「はい」をクリックする。
    f:id:hkob:20200404154803p:plain
    権限の確認
  • Chocolatey のページに書かれてインストールスクリプトを実行する
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  • 実行するとこんな画面になる。
    f:id:hkob:20200404155350p:plain
    インストールスクリプトの実行

Chocolatey の使い方

macOS の Homebrew と同様にインストールできるアプリはコマンドで検索できる。

内容 コマンド
アプリを探す choco search アプリ名
アプリをインストール cinst アプリ名 (choco install アプリ名よりも簡単)
アプリをアップグレード choco upgrade アプリ名

ここでは、Google Chrome をインストールする場合を例として説明する。

  • まず「google-chrome」を検索する。
PS C:\Windows\system32> choco search google-chrome
Chocolatey v0.10.15
2 validations performed. 1 success(es), 1 warning(s), and 0 error(s).

Validation Warnings:
 - A pending system reboot request has been detected, however, this is
   being ignored due to the current command being used 'search'.
   It is recommended that you reboot at your earliest convenience.

google-chrome-for-enterprise 67.0.3396.87 [Approved] Downloads cached for licensed users - Possibly broken for FOSS users (due to original download location changes by vendor)
google-chrome-x64 47.0.2526.81 [Approved]
GoogleChrome 80.0.3987.162 [Approved] Downloads cached for licensed users
GoogleChrome.Canary 28.0.1461.0 [Approved]
GoogleChrome.Dev 27.0.1453.12 [Approved]
googlechrome-authy 2.3.0 [Approved]
GoogleChrome-AllUsers 26.0.1410.64 - Possibly broken
selenium-chrome-driver 80.0.3987.106 [Approved] Downloads cached for licensed users
8 packages found.
  • GoogleChrome がパッケージ名だとわかるので、これをインストールする。途中でインストールするかどうか聞かれる。これが面倒な場合には「cinst GoogleChrome --yes」のように「--yes」オプションを付けると強制的にインストールしてくれる。
PS C:\Windows\system32> cinst GoogleChrome
Chocolatey v0.10.15
2 validations performed. 1 success(es), 1 warning(s), and 0 error(s).

Validation Warnings:
 - A pending system reboot request has been detected, however, this is
   being ignored due to the current Chocolatey configuration.  If you
   want to halt when this occurs, then either set the global feature
   using:
     choco feature enable -name=exitOnRebootDetected
   or pass the option --exit-when-reboot-detected.

Installing the following packages:
GoogleChrome
By installing you accept licenses for the packages.
Progress: Downloading chocolatey-core.extension 1.3.5.1... 100%
Progress: Downloading GoogleChrome 80.0.3987.163... 100%

chocolatey-core.extension v1.3.5.1 [Approved]
chocolatey-core.extension package files install completed. Performing other installation steps.
 Installed/updated chocolatey-core extensions.
 The install of chocolatey-core.extension was successful.
  Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-core'

GoogleChrome v80.0.3987.163 [Approved]
googlechrome package files install completed. Performing other installation steps.
The package GoogleChrome wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): Yes

Downloading googlechrome 64 bit
  from 'https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise64.msi'
Progress: 100% - Completed download of C:\Users\hkob\AppData\Local\Temp\chocolatey\GoogleChrome\80.0.3987.163\googlechromestandaloneenterprise64.msi (57.84 MB).
Download of googlechromestandaloneenterprise64.msi (57.84 MB) completed.
Hashes match.
Installing googlechrome...
googlechrome has been installed.
  googlechrome may be able to be automatically uninstalled.
 The install of googlechrome was successful.
  Software installed as 'MSI', install location is likely default.

Chocolatey installed 2/2 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
  • Windows アイコンをクリックしてみると、「Google Chrome」が新規にインストールされていることがわかる。
    f:id:hkob:20200404163300p:plain
    アプリケーションメニュー

以上。

hkob.hatenablog.com