5/25/2019»»Saturday

Choco Package Manager

5/25/2019
    79 - Comments
  1. Choco Windows

My goal is to create a single script that I can download and run on a fresh Windows build to set up the system as much as possible. The first thing I am trying to do is install as many of the programs that I always like to have available as possible. I previously ran this (it is from chocolatey.org) to install Chocolatey directly from PowerShell:

Then I ran a bunch of choco installs like this:

(I think the -y makes them run without a prompt.)

The script should check if Chocolatey is installed and if not, run the install script. Then it should loop through a list of package names and silently install them.

  • How do I detect if Chocolatey is already installed?
  • How do I conditionally run the install command based on that result?
  • How do I loop through a list of packages and run the choco install command on each?

If you have any suggestions on how to accomplish my main goal using other means, please let me know. Autocad 2012 crack xforce.

Benjamin CuninghamBenjamin Cuningham

3 Answers

All of your questions could be answered by looking at the PowerShell help files and Microsoft tech documentation:

For loops

(I think the -y makes them run without a prompt.)

Correct, and it should always be used in scripting.

The script should check if Chocolatey is installed and if not, run the install script. Then it should loop through a list of package names and silently install them.

• How do I detect if Chocolatey is already installed?

Use the link above - or there is an environment variable set on installation, ChocolateyInstall which is set to C:ProgramDataChocolatey by default.

A more deterministic way may be to try

• How do I conditionally run the install command based on that result?

Nuget

Using an if statement:

Choco Package Manager

• How do I loop through a list of packages and run the choco install command on each?

Using a for loop:

Alternative / Enhancement

Microsoft has a built-in package manager manager called PackageManagement (built into PowerShell v5). You can use it with a ChocolateyGet provider (don't use the prototype Chocolatey provider, it is broken and has security issues) for managing third-party dependencies.

The advantage of PackageManagement is that it also has PowerShellGet for managing PowerShell modules.

Package

Just type.

List all available modules / packages

For PowerShell version 3 - 4, you have to download and install PowerShellGet.

postanotepostanote

I actually made a batch script which uses the functionality of chocolately itself(config files). You can look it up here. Just change the packages in the config files.

RiddimRiddim

Actually Microsoft have been working on a windows-dev-box-setup-scripts to accomplish that, using boxstarter and chocolatey

As an open source project you can fork it or download it and adapt it to your needs

Hope it helps :)

ddieppaddieppa

Choco Windows

Not the answer you're looking for? Browse other questions tagged powershellchocolatey or ask your own question.