Skip to content

Instantly share code, notes, and snippets.

@zaccb
Last active December 10, 2023 08:54
Show Gist options
  • Save zaccb/f57988424df89a35f4dab9fc8b789685 to your computer and use it in GitHub Desktop.
Save zaccb/f57988424df89a35f4dab9fc8b789685 to your computer and use it in GitHub Desktop.
Chocolatey install script
:: Install choco .exe and add choco to PATH
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
:: Install all the packages
:::: Browsers
choco install googlechrome -fy
choco install firefox -fy
:::: Text editors / IDEs
choco install atom -fy
choco install sublimetext3 -fy
choco install visualstudiocode -fy
choco install visualstudio2015community -fy
:::: Dev tools
choco install git -fy
choco install nodejs.install -fy
:::: Media
choco install vlc -fy
:::: Utilities + other
choco install 7zip.install -fy
choco install dropbox -fy
choco install slack -fy
choco install office365proplus -fy
@Wisedemic
Copy link

I just thought to make this, and so I googled it. I stumbled upon this to see it has already been made!

Thanks for the script! @PowerShell is a beautiful thing.

@zaccb
Copy link
Author

zaccb commented Jun 12, 2018

@Wisedemic Glad that you found it helpful! I had to spin up a new VM this morning for a dev environment and used this again - still works! Generates a few warnings, but nothing blocking. There's a lot of other config that can be easily added to this with @PowerShell, depending on how you have your box setup.

@rusticrajp
Copy link

Great stuff!
Is there a way to install VM in hyper-v using this? so I don't want to go thru the OS setup process. I want to install OS in VM and also install all packages.

@phihos
Copy link

phihos commented Sep 19, 2018

Thank you very much for the script.
For people who are lazy like me:

Create an extra file packages.txt in the same folder with content like

# browsers
googlechrome 
firefox
# Text editors / IDEs
sublimetext3
...

And replace all choco install calls with

for /F "eol=#" %%G in (packages.txt) do choco install %%G -fy

Lines prefixed with # will be excluded automatically.

This reduces the typing work while preserving the ability to easily remove packages.

@tpund
Copy link

tpund commented Mar 5, 2019

Using upgrade also installs. The following can be run at will to install on a fresh system or upgrade packages on existing.

`@echo off
echo Administrative permissions required. Detecting permissions ...

net session >nul 2>&1
if %errorLevel% == 0 (
ECHO Okay ...
IF EXIST "C:\ProgramData\chocolatey\bin\chocolatey.exe" (
ECHO Chocolatey is already installed ...
choco upgrade chocolatey chocolatey-core.extension -y
) ELSE (
ECHO Installing Chocolatey ...
@PowerShell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
)
ECHO Checking packages ...
for /F "eol=#" %%G in (packages.txt) do choco upgrade %%G -y
) else (
echo Failure: Current permissions inadequate.
)`

packages.txt:
package_1
package_2
package_3
#ignored_package_4
package_5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment