You have apps on your computer like Spotify, Adobe Reader, Chrome, Firefox, 7-Zip, VLC Media Player… the list goes on and they are all free. What would we do if we don’t have free software? However, these apps require regular updates to fix security holes and introduce new and useful features. Updates never happen at a convenient time.
That’s where Chocolatey comes into play. Use the free Chocolatey app to update your software. It’s easy, fast, simple and did we mention free? It seems too good to be true, but it is. But what is Chocolatey?
What is Chocolatey?
If you have not done the things in Windows command line, PowerShellor Linux command line, the concept of Chocolatey can be a bit weird. Chocolatey is a machine-level program that helps you manage software.
Machine level means no graphical user interface to help you do everything. All commands must be entered. Don’t let that scare you! If you can write words, you can master this.
How to install Chocolatey?
There are several things that Chocolatey needs to function. When a program needs other programs of Windows features to work, those necessary programs are called dependencies. Chocolatey dependencies at least you have to use:
- Windows 7 and above
- PowerShell version 2 or later
- .NET Framework 4 or later
- In addition, you must have administrator access rights on your computer
If you have Windows 7 or later, you already have PowerShell version 2 or later. If you’re not sure if you have the .NET Framework 4, don’t worry. When you install Chocolatey, if you don’t have .NET 4, Chocolatey will install it for you.
Open PowerShell by typing Start MenuPowerShell’s search box. You will see a result named Windows PowerShell Apps.
Right click on it and select Run as administrator. Doing this is called running PowerShell in advanced case. It is elevated to Administrator privilege. A PowerShell window will open.
In the PowerShell window, type or copy and paste the command:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient) .DownloadString (‘https://chocolatey.org/install.ps1’))
The Set-ExecutionPolicy Bypass -Scope Process -Force
part tells PowerShell that you don’t want to enforce a restricted execution policy just for this next thing. PowerShell, by default, will only allow signed processes to run. This is the highest security setting. But we need to run this unsigned Chocolatey installation.
The iex ((New-Object System.Net.WebClient) .DownloadString (‘https://chocolatey.org/install.ps1’))
part of the command tells PowerShell to visit the Chocolatey website, download the install.ps1 script, and run it. That’s the part that actually installs Chocolatey.
You’ll see a bunch of text scroll through. Go back and read it so you know what just happened. Finally, it suggests that you run the command choco /? to see a list of functions. That’s a good way to make sure your installation works. Go ahead and run that command.
Another pile of text will fly by, which is also great to read and understand. Finally, if your Chocolatey installation worked, you should see something like the following, where the green section lists the version you just installed.
Install software with Chocolatey
Let’s take a quick look at how to install software with Chocolatey before we update the software with it.
Go to page https://chocolaty.org/packages to browse the software available through Chocolatey. You will see that they are called packages.
Find a package that you want to install. For this example we will use Malwarebytes Anti-Malware. It’s always good to have Malwarebytes on your computer.
In the enhanced version of PowerShell, use the command choco install malwarebytes. That’s it. The installation process will begin. It will stop with the following text:
If you are comfortable allowing Chocolatey to manage your software, then when this installation is complete we should use choco feature enable -n allowGlobalConfirmation command so that we can automatically install and update in the future. For now, let’s use One to complete the installation.
You should see that Malwarebytes is downloading and then starting to install.
In about a minute, Malwarebytes will be downloaded and installed without you needing to do any more.
Update software with Chocolatey
Now that we have some software installed, we can try updating it with Chocolatey. Again, you need to open PowerShell as Administrator. Then you can run the command choco malware upgrade.
That will make Chocolatey go out and see if there is an update and then update it. We have just installed Malwarebytes, so it will show that there is not a single updated package. It’s okay.
If you have several packages installed with Chocolatey, you can update them all with the one-line command: choco upgrade all -y.
It’s as difficult as it gets. Now what we have to do to automatically update the software with Chocolatey is somehow make that command run on schedule.
Automatic software updates with Chocolatey
The next step you can do is using Wither Notepad or PowerShell ISE (Integrated Scripting Environment). We will do this example using Notepad because not all versions of Windows have PowerShell ISE.
Open Notepad. Copy command choco upgrade all -y into Notepad.
Save it as a PowerShell script by naming it something like upgrade-ChocoPackages.ps1. The .ps1 extension tells Windows that this is a PowerShell script.
Change the file type from Text Document (*.txt) arrive All files (*.*). If you don’t, Windows will make it upgrade-ChocoPackages.ps1.txt and thought it was just a Notepad file.
Windows comes with a great feature called Board plan. The average home user might not know about it, but the Task Scheduler is a feature that has kept a lot of things running on a regular basis.
In the Start Menu, search on Task Scheduler. Click on it when it appears.
When Task Scheduler opens, click Task Scheduler Library in the top left area of the window. This will show you all the scheduled tasks that are currently set up on your computer.
inside Act in the top right area, click Create jobs…. Creating a Basic Task is not suitable for this case, as we will be using the following argument statements.
In the window that opens, in Shared name the task like Choco Upgrade all and then a Description alike Update all software installed by Chocolatey. If your current user account is not an administrator account on your computer, use Change user or group to select the Administrator account.
You will also need to know the password of the Administrator account. Guaranteed Run whether user is logged in or not chosen. This will allow the script to run even when you are not on your computer and it will have all the necessary privileges to do the job.
The Cause tab is where you tell the task when you want it to run. For this, once a week should be plenty. In our example, it is set to run every Sunday at 1:00 am. Choose a time when you are most likely not using your computer for best performance.
You should also check Stop the task if it runs longer: and change the duration to 2 hours. You can adjust that to your liking. To allow the trigger to apply, you must check Enabled box at the bottom.
Via Act and we’ll let the task know what we want it to do. The Work will default to Start a program. That’s what we wanted so just leave that. inside Program / scenario field, type powershell.exe. This lets Windows know you’re about to run a PowerShell script.
inside Add arguments Please enter the following arguments.
-No profile – This prevents PowerShell profile scripts from running and tells it to run only the scripts you want.
-ExecutionPolicy Bypass – If you are not sure whether script execution is enabled, it is better to have this in the arguments. It will make sure the script runs.
-file This is the argument that tells the Task Scheduler that whatever comes next is the path to the file we want PowerShell to run. In our example, the script was saved to C: \ Scripts \ lift-ChocoPackages.ps1. It may be different on your computer, so adjust accordingly. If the path to your file has any names with spaces, you’ll need to enclose the entire path inside quotes.
What would the full argument look like? -noprofile -executionpolicy bypass -file C:\Scripts\lift-ChocoPackages.ps1
Above Conditions , there are more options we can set about how to run the script. Look at them to see which one you want to apply. For this example it is set to Start the task only if the computer is using AC power and Stop if the computer switches to battery power to make sure we don’t run out of batteries.
Wake up the computer to run this task is selected to ensure the task runs, whether or not the computer is in sleep mode.
inside Setting you should check Allow running tasks on demand so we can check the task manually when we’re done. The default choices for the rest are fine.
Click ALRIGHT to finish creating the scheduled task. A window will pop up with the name of the user you selected back on the General tab. You have to enter the password for the user and click ALRIGHT. This tells Windows that you actually have permission to run the task.
Now you return to the main Task Scheduler window. Find your new mission. Right click on the task and select Run to check it.
You won’t see anything important happen, except that the status of the quest will change to Running. In a minute or so, you’ll see Last run time also changes to timestamp when you start running the task.
If you don’t get any error messages, the task should be fine. Close the Task Scheduler window and don’t worry about having to manually update any software you installed with Chocolatey.
All has been done!
Seems like a lot of work to set this up. Consider this: it took you about 10 to 30 minutes to set this up. If you are using this permission to update 10 programs and each program takes about 6 minutes to do the monthly update process, you have saved yourself 30 to 50 minutes.
You have gone ahead in time saved. Over the course of a year, 6 to 10 hours of time can be saved. Not to mention the time saved by knowing how to use Chocolatey to install programs in a minute or two instead of 10 or 15.