WindowsではLinux系みたいにコマンドラインからソフトをほぼ自動的にインストールできないことが多い。そういうかゆいところを解決してくれるのがこのchocolateyというソフト。インストールから各種ソフトのインストールまでなれると、っというよりはこういう事をしようとしている人にはすぐに慣れるので色々と楽ちんです。
また、会社のシスアドみたいなところでIT管理を任されていたりし 且つ フリーソフトがOKな管理者には日々の仕事を楽にしてくれる事間違いないかと。
ただし、自分用のデバッグマシンで最初に試してからにしましょうね。
chocolateyのウェブサイト(https://chocolatey.org/)
コンテンツ
インストール方法
コマンドラインにて
chocolateyをインストールするには、コマンドプロンプトを管理者権限で作動し、以下をコマンドラインにコピー&ペーストし実行する。
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
インストール中は以下の様な感じです。
C:\>@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object ne t.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH= %PATH%;%ALLUSERSPROFILE%\chocolatey\bin Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 2016/03/20 14:16 chocInstall Downloading https://packages.chocolatey.org/chocolatey.0.9.9.12.nupkg to C:\Use rs\mike\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip Download 7Zip commandline tool Downloading https://chocolatey.org/7za.exe to C:\Users\mike\AppData\Local\Temp \chocolatey\chocInstall\7za.exe Extracting C:\Users\mike\AppData\Local\Temp\chocolatey\chocInstall\chocolatey. zip to C:\Users\mike\AppData\Local\Temp\chocolatey\chocInstall... 7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Processing archive: C:\Users\mike\AppData\Local\Temp\chocolatey\chocInstall\cho colatey.zip Extracting _rels\.rels Extracting chocolatey.nuspec Extracting tools\chocolateyInstall.ps1 Extracting tools\chocolateysetup.psm1 Extracting tools\init.ps1 Extracting tools\chocolateyInstall\choco.exe Extracting tools\chocolateyInstall\choco.exe.ignore Extracting tools\chocolateyInstall\LICENSE.txt Extracting tools\chocolateyInstall\helpers\chocolateyInstaller.psm1 Extracting tools\chocolateyInstall\helpers\chocolateyScriptRunner.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-BinRoot.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-CheckSumValid.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-ChocolateyUnzip.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-ChocolateyWebFile.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-EnvironmentVariable.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-EnvironmentVariableNames.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-FtpFile.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-ProcessorBits.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-UACEnabled.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-VirusCheckValid.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-WebFile.ps1 Extracting tools\chocolateyInstall\helpers\functions\Get-WebHeaders.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-BinFile.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyDesktopLink.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyEnvironmentVariable.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyExplorerMenuItem.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyFileAssociation.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyInstallPackage.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyPackage.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyPath.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyPinnedTaskBarItem.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyPowershellCommand.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyShortcut.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyVsixPackage.ps1 Extracting tools\chocolateyInstall\helpers\functions\Install-ChocolateyZipPackage.ps1 Extracting tools\chocolateyInstall\helpers\functions\Set-EnvironmentVariable.ps1 Extracting tools\chocolateyInstall\helpers\functions\Start-ChocolateyProcessAsAdmin.ps1 Extracting tools\chocolateyInstall\helpers\functions\Test-ProcessAdminRights.ps1 Extracting tools\chocolateyInstall\helpers\functions\Uninstall-BinFile.ps1 Extracting tools\chocolateyInstall\helpers\functions\Uninstall-ChocolateyPackage.ps1 Extracting tools\chocolateyInstall\helpers\functions\UnInstall-ChocolateyZipPackage.ps1 Extracting tools\chocolateyInstall\helpers\functions\Update-SessionEnvironment.ps1 Extracting tools\chocolateyInstall\helpers\functions\Write-ChocolateyFailure.ps1 Extracting tools\chocolateyInstall\helpers\functions\Write-ChocolateySuccess.ps1 Extracting tools\chocolateyInstall\helpers\functions\Write-FileUpdateLog.ps1 Extracting tools\chocolateyInstall\redirects\choco.exe Extracting tools\chocolateyInstall\redirects\choco.exe.ignore Extracting tools\chocolateyInstall\redirects\chocolatey.exe Extracting tools\chocolateyInstall\redirects\chocolatey.exe.ignore Extracting tools\chocolateyInstall\redirects\cinst.exe Extracting tools\chocolateyInstall\redirects\cinst.exe.ignore Extracting tools\chocolateyInstall\redirects\clist.exe Extracting tools\chocolateyInstall\redirects\clist.exe.ignore Extracting tools\chocolateyInstall\redirects\cpack.exe Extracting tools\chocolateyInstall\redirects\cpack.exe.ignore Extracting tools\chocolateyInstall\redirects\cpush.exe Extracting tools\chocolateyInstall\redirects\cpush.exe.ignore Extracting tools\chocolateyInstall\redirects\cuninst.exe Extracting tools\chocolateyInstall\redirects\cuninst.exe.ignore Extracting tools\chocolateyInstall\redirects\cup.exe Extracting tools\chocolateyInstall\redirects\cup.exe.ignore Extracting tools\chocolateyInstall\redirects\cver.exe Extracting tools\chocolateyInstall\redirects\cver.exe.ignore Extracting tools\chocolateyInstall\redirects\RefreshEnv.cmd Extracting tools\chocolateyInstall\tools\7za.exe Extracting tools\chocolateyInstall\tools\7za.exe.ignore Extracting tools\chocolateyInstall\tools\7za.exe.manifest Extracting tools\chocolateyInstall\tools\7zip.license.txt Extracting tools\chocolateyInstall\tools\checksum.exe Extracting tools\chocolateyInstall\tools\checksum.exe.ignore Extracting tools\chocolateyInstall\tools\checksum.license.txt Extracting tools\chocolateyInstall\tools\shimgen.exe Extracting tools\chocolateyInstall\tools\shimgen.exe.ignore Extracting tools\chocolateyInstall\tools\shimgen.license.txt Extracting package\services\metadata\core-properties\e5c910884a984a4bb9ab3cbc853d7a13.psmdcp Extracting [Content_Types].xml Everything is Ok Files: 76 Size: 4894067 Compressed: 1806795 Installing chocolatey on this machine Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' 警告: It's very likely you will need to close and reopen your shell before you can use choco. Adding Modify permission for current user to 'C:\ProgramData\chocolatey' We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName '. Creating Chocolatey folders if they do not already exist. 警告: You can safely ignore errors related to missing log files when upgrading from a version of Chocolatey less than 0.9.9. 'Batch file could not be found' is also safe to ignore. 'The system cannot find the file specified' - also safe. chocolatey.nupkg file not installed in lib. Attempting to locate it from bootstrapper. PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding... Chocolatey (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. Run choco /? for a list of functions. You may need to shut down and restart powershell and/or consoles first prior to using choco. Ensuring chocolatey commands are on the path Ensuring chocolatey.nupkg is in the lib folder C:\>
PowerShellにて
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
各種ソフトのインストール方法
管理者権限で実行するように
ソフトのインストール時はコマンドプロンプトを管理者権限で実行してからソフトのインストールを行いましょう。でないとエラーが表示されてしまいます。以下エラーの内容。
C:\choco install k-litecodecpackfull Chocolatey detected you are not running from an elevated command shell (cmd/powershell). You may experience errors - many functions/packages require admin rights. Only advanced users should run choco w/out an elevated shell. When you open the command shell, you should ensure that you do so with "Run as Administrator" selected. Do you want to continue? 1) yes 2) no
K-Lite Codec Packの場合
choco install k-litecodecpackfull -y
なお、「-y」がついているのはインストールしますかYes/Noを表示させずに自動でインストールするため。
インストール中はこのような感じ
C:\WINDOWS\system32>choco install k-litecodecpackfull -y Installing the following packages: k-litecodecpackfull By installing you accept licenses for the packages. k-litecodecpackfull v12.0.1 Downloading k-litecodecpackfull 32 bit from 'http://download.betanews.com/download/1094057842-3/K-Lite_Codec_Pack_1201_Full.exe' Hashes match. Installing k-litecodecpackfull... k-litecodecpackfull has been installed. The install of k-litecodecpackfull was successful. Chocolatey installed 1/1 package(s). 0 package(s) failed. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). C:\WINDOWS\system32\
7-Zip 15.14 (31DEC2015 Release)の場合
choco install 7zip.install -y
インストール状況。既に前のバージョンの7-Zipがインストールされていたので普通にはインストールされなかったので「–force」パラメータを使用しインストール。
choco install 7zip.install -y --force
C:\WINDOWS\system32>choco install 7zip.install -y Installing the following packages: 7zip.install By installing you accept licenses for the packages. 7zip.install v15.14 already installed. Use --force to reinstall, specify a version to install, or try upgrade. Chocolatey installed 0/1 package(s). 0 package(s) failed. 1 package(s) had warnings. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). Warnings: - 7zip.install C:\WINDOWS\system32>choco install 7zip.install -y --force Installing the following packages: 7zip.install By installing you accept licenses for the packages. 7zip.install v15.14 (forced) 警告: This installer is known to close the explorer process. This means you may lose current work. If it doesn't automatically restart explorer, type 'explorer' on the command shell to restart it. Downloading 7zip.install 64 bit from 'http://www.7-zip.org/a/7z1514-x64.exe' Installing 7zip.install... 7zip.install has been installed. The install of 7zip.install was successful. Chocolatey installed 1/1 package(s). 0 package(s) failed. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). C:\WINDOWS\system32>
バージョンを調べてみるとちゃんと最新の15.14がインストールされていた。
インストールしている時に遭遇する問題
アンチウイルスソフトが邪魔して正常にインストールされてると表示されても、インストールが途中で終わっている事もあるので、そういう時は強制的に再インストールをすれば問題なくインストールできる。なぜかK-Lite Codecをインストールしようとしたときにトロイの木馬と間違えられる。その後の強制インストールでは問題なくインストールは成功。
他のソフト~
以下のURLを参照
Chocolatey Packages(https://chocolatey.org/packages)