Chocolateyを使ってWindows10の初期設定
はじめに
通常Windows10にアプリケーションをインストールする場合、Webサイトからプログラムをダウンロードして
セットアップを行ったり、DVDからセットアップを行うのが一般的だが、セットアップする資材が多いと非常に手間となる。
Ubuntuだと、パッケージ管理のaptを使用すれば、セットアップシェルを作成し、自動でインストール出来る。
Widnowsで同様なことをする場合、Chocolateyを使用すれば可能。
少し試してみたが、簡単だったので利用してみる。
必要なもの
# | 名称 | URL |
---|---|---|
1 | Chocolatey | https://chocolatey.org/ |
Chocolateyのインストール
https://chocolatey.org/installにインストール方法が
記載されているので、手順に従いインストールを行う。
管理者権限でPowershellかcmdを起動
以下コマンドを実行する。
1 2 3 |
# Powershellの場合 Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) |
chocolateyのバージョン確認
以下の様にバージョンが確認できれば完了
1 2 3 4 5 |
# バージョン確認 PS C:\Windows\system32> choco -v 0.10.11 PS C:\Windows\system32> |
試しに「ScreenPresso」をインストールしてみる
無料で画面キャプチャをとれる「Screenpresso」をインストールする。
パッケージの検索
ChocolateyのPackage検索で、「Screenpresso」を検索する。
インストールコマンドが表示されるので、Powershellからインストールを行う。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
PS C:\Windows\system32> choco install screenpresso Chocolatey v0.10.11 Installing the following packages: screenpresso By installing you accept licenses for the packages. Progress: Downloading screenpresso 1.7.5.1... 100% screenpresso v1.7.5.1 [Approved] screenpresso package files install completed. Performing other installation steps. The package screenpresso 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/[N]o/[P]rint): y Downloading screenpresso 64 bit from 'https://www.screenpresso.com/binaries/v1/Screenpresso.exe' Progress: 100% - Completed download of C:\Users\Developer\AppData\Local\Temp\chocolatey\screenpresso\1.7.5.1\Screenpresso.exe (12.11 MB). Download of Screenpresso.exe (12.11 MB) completed. Hashes match. Installing screenpresso... screenpresso has been installed. screenpresso can be automatically uninstalled. The install of screenpresso was successful. Software installed to 'C:\Program Files\Learnpulse\Screenpresso' Chocolatey installed 1/1 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). PS C:\Windows\system32> |
aptのcacheみたいに、インストールしたファイルは、保存される。
インストール後の確認
以下の様に、インストールが完了した。
各ソフトウェアのインストール
screenpresso同様に以下のソフトをインストールした。
サクラエディタについては、インストールオプションを追加した。
# | 名称 | インストールコマンド | 分類 | メモ |
---|---|---|---|---|
1 | SakuraEditor | choco install sakuraeditor | 多機能エディタ | オプションを指定しない場合 |
2 | SakuraEditor | choco install sakuraeditor --params "'/Tasks:startmenu,desktopicon,!quicklaunch,fileassoc'" | 多機能エディタ | オプションを指定する場合 |
3 | Google Chrome | choco install googlechrome | ブラウザ | VMだとlatestにならない |
4 | Slack | choco install slack | ツール | |
5 | 7-zip | choco install 7zip.install | アーカイバ | |
6 | Visual Studio Code | choco install vscode | 開発エディタ | |
7 | Winmerge | choco install winmerge | ツール | |
8 | VirtualBox | choco install virtualbox | 仮想化 | |
9 | Vagrant | choco install vagrant | 仮想化支援 |
VM上での挙動不正
ChocolateyをVMで使用すると、latestのバージョンを取得しない場合があるので
「-y」をつけずに、バージョンを都度確認したほうがよい。
latestのバージョンをPackage検索で確認し、バージョンオプション(--version)を追加する必要がある
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
## --versionを指定しない。通常はlatestになるはずだが、古いバージョンが選択される。 PS C:\Windows\system32> choco install googlechrome Chocolatey v0.10.11 Installing the following packages: googlechrome By installing you accept licenses for the packages. Progress: Downloading GoogleChrome 38.0.2125.111... 100% GoogleChrome v38.0.2125.111 [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/[N]o/[P]rint): n ## --versionを指定し、latestにする PS C:\Windows\system32> choco install googlechrome --version 73.0.3683.75 Chocolatey v0.10.11 Installing the following packages: googlechrome By installing you accept licenses for the packages. Progress: Downloading GoogleChrome 73.0.3683.75... 100% GoogleChrome v73.0.3683.75 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/[N]o/[P]rint): y |
latestの調査
以下の様に「packages.txt」に必要なPackageを追加し、Latest調査するPowershellに引数で渡すと、Latestを調べて、インストールコマンドを作成するようにした。
1 2 3 4 5 6 7 8 9 10 |
# packages.txt sakuraeditor googlechrome slack 7zip.install vscode winmerge virtualbox vagrant |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# searchLatest.ps1 #powershell Set-ExecutionPolicy RemoteSigned $PARAMS_MAP = @{ "sakuraeditor" = "--params `"'/Tasks:!quicklaunch,fileassoc'`"" } # 引数のファイル読込 $data = cat $args foreach ( $dt in $data) { $cmd = (choco list $dt --all | select-string "^$dt") | Select-Object -first 1 | % {"cinst -y " + $($_ -split(' '))[0] + " --version " + $($_ -split(' '))[1]} Write-Host $cmd $PARAMS_MAP["$dt"] } #powershell Set-ExecutionPolicy Restricted pause |