Chocolatey - install programs with commands (for Windows)

Grab a cup of coffe and attend to the more simple things in life.
Post Reply
User avatar
+Colibri
Administrator
Posts: 3958
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Chocolatey - install programs with commands (for Windows)

Post by +Colibri »

Since my computer crashed a few times, I got tired of downloading programs and installing them, so I've found chocolatey. And along with other powershell trickery, it can be really quick to customize windows to your liking.

Basically, you could install programs by typing the following in PowerShell (i guess regular Command Prompt also works)

Code: Select all

choco install notepadplusplus
choco install winrar
choco install firefox

Installing chocolatey
But first, you have to install chocolatey on your system. More info here: https://chocolatey.org/install
And here's a trick so you won't keep getting prompts "do you want to install...? [y/n]" for every program - run this command:
choco feature enable -n allowGlobalConfirmation
I also recommend installing "ChocolateyGUI", a graphical tool to see what all is installed (or needs updating, or to uninstall it).

I know that some of you are still using Windows versions before Win 10, I don't know how far back this goes in terms of compatibility, but I assume that those of you who are interested in such tinkering, have already switched to Windows 10 :)

So the whole installation command is:
Run at your own risk - this is the batch of commands i use, and from what I see it's all safe, but I don't take any responsibility.
Right-click on the Windows button (bottom left of the screen) and click "Windows PowerShell (Admin)".
Run the following commands to install everything (RUN AT YOUR OWN RISK!).

Code: Select all

Set-ExecutionPolicy Bypass -Scope Process -Force; 
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco feature enable -n allowGlobalConfirmation
choco install ChocolateyGUI

And after that you can install your programs. To find the names of the programs you want to install, just go to the Chocolatey website and click "Find packages", here's the link: https://community.chocolatey.org/packages

Here are the ones I use:
choco install ChocolateyGUI
choco install notepadplusplus
choco install veracrypt
choco install imdisk-toolkit
choco install firefox
choco install googlechrome
choco install vlc
choco install windirstat
choco install libreoffice-fresh
choco install winrar
choco install adobereader
choco install vscode
choco install pingplotter
choco install nircmd




You can also combine this with other powershell commands, like editing the registry. This way, you don't have to go thru the menus and click options to your liking, but just do it in less than a second. Here's snippets from my config script:

Code: Select all

#Change computer name: 
Rename-Computer -NewName "Server0001"


#Hide cortana button on the taskbar
New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'ShowCortanaButton' -Value 0 -PropertyType DWORD -Force
#command prompt: disable quick edit.
Set-ItemProperty -Path HKCU:\Console -Name QuickEdit -Value 0
#show hidden files and folders
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Hidden -Value 1
#show file extensions
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name HideFileExt -Value 0
#run as separate process
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name SeparateProcess -Value 1

#Taskbar buttons: never combine
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -Value 2
#Multi-monitor taskbar: show buttons on: taskbar where window is open
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name MMTaskbarMode -Value 2
#Multi-monitor taskbar: combine buttons on other taskbars: never
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name MMTaskbarGlomLevel -Value 2
#hide search bar from taskbar
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchBoxTaskbarMode -Value 0 -Type DWord -Force

#stop explorer to apply the changes, no need to start it since it will restart itself.
Stop-Process -Name "Explorer"

#power & sleep settings - disable sleep
Powercfg /Change standby-timeout-ac 0
Powercfg /Change standby-timeout-dc 0


#fix browser opening - so it opens firefox instead of internet explorer
Set-ItemProperty -Path HKLM:\SOFTWARE\Classes\htmlfile\shell\open\command -Value "C:\Program Files\Mozilla Firefox\firefox.exe" -Name "(Default)" -Type String -Force
(the last one is from our wiki page: https://www.uoex.net/wiki/Fix_Browser_Opening)



A more known and perhaps more user friendly (but not as cool 8) :geek: ) alternative to Chocolatey is https://ninite.com/

I've been wanting to post this here for a long time, and this just came up as a discussion in another forum and it reminded me. I hope you find it useful!
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
Post Reply