Your computer has apps like Spotify, Adobe Reader, Chrome, Firefox, 7-Zip, VLC Media Player the list goes on, and they’re all free. What would we do without free software? However, these apps require frequent updates to fix security holes and introduce useful new features. Updates never happen at a convenient time.
This is where Chocolatey comes into play. Use the free Chocolatey app to update your software. It’s easy, fast, simple, but did we mention free? It seems too good to be true, but it is. But what is Chocolatey?
What is chocolate?
Machine level means no graphical user interface to help you do things. All commands must be typed. Don’t let this scare you! If you can write words, you can handle it.
How do I install Chocolatey?
There are a couple of things to do for Chocolatey to work. When a program requires other Windows function programs to function, those required programs are called dependencies. Chocolatey’s dependencies are that you should be using at least:
- Windows 7 or newer
- PowerShell version 2 or newer
- .NET Framework 4 or newer
- In addition, you must have administrator rights on your computer.
If you have Windows 7 or newer, you already have PowerShell 2 or newer. If you’re not sure if you have .NET Framework 4, don’t worry. When installing Chocolatey, if you don’t have .NET 4, Chocolatey will install it for you.
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 the restricted execution policy for this next only. PowerShell allows only signed processes to run by default. This is the highest level of security. But we need to run this unsigned Chocolatey installation process.
The iex ((New-Object System.Net.WebClient) .DownloadString (‘https://chocolatey.org/install.ps1’)) part of the command tells PowerShell to go to the Chocolatey website, download the install.ps1 script, and run it This is the part that actually installs Chocolatey.
You will see a bunch of text fly by. Feel free to come back and read this to know what just happened. At the end, it is suggested to run the command choco /? to see the list of functions. This is a good way to make sure your setup works. Let’s run this command.
Another heap of text will fly by, which is also good to read and understand. At the end, if your Chocolatey installation worked, you will see something like the following, where the green part indicates the version you just installed.
Install the program with Chocolatey
Let’s take a quick look at installing the software with Chocolatey before we start updating it.
Go to https://chocolatey.org/packages to view the software available through Chocolatey. You will see that they are called packages.
Find the package you want to install. For this example, we will be using Malwarebytes Anti-Malware. It’s always good to have Malwarebytes on your computer
In an elevated instance of PowerShell, use the choco install malwarebytes command. This is it. Installation starts. It will stop with the following text:
If you are comfortable with allowing Chocolatey to manage your software, then when this installation is complete we must use the choco feature enable -n allowGlobalConfirmation command so that we can automate future installations and updates. For now, let’s just use A to complete the installation.
You will see Malwarebytes downloading and then starting the installation.
In about a minute, Malwarebytes will be downloaded and installed without any additional steps for you.
Software update 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 choco upgrade malwarebytes command.
This will force Chocolates to come out and see if there is an update, then update it. We just installed Malwarebytes, so it will show zero packages have been updated. Nothing wrong.
If you’ve installed multiple packages using Chocolatey, you can upgrade them all with a one-line command: choco upgrade all -y.
This is more difficult than ever. Now, in order to automatically update the software with Chocolatey, we have to somehow get this command to run on schedule.
Automatic software update using Chocolatey
Open Notepad. Copy the choco upgrade all -y command into Notepad.
Change the file type from Text Documents (* .txt) to All Files (*. *). If you don’t, Windows will upgrade-ChocoPackages.ps1.txt and think it’s just a Notepad file.
Windows has a great feature called Task Scheduler. The average home user probably doesn’t know about this, but the task scheduler is a feature that already makes a lot of things run on a regular basis.
In the Start menu, find Task Scheduler. Click on it when it appears as a result.
When Task Scheduler opens, click on â€œTask Scheduler Libraryâ€ in the upper left corner of the window. This will show you all the scheduled tasks that are currently configured on your computer.
In the Actions pane in the upper right corner, click Create Task . Create Basic Task is not suitable for this situation, as we will use the arguments later.
In the window that opens, on the General tab, give the task a name, such as Choco Upgrade All, and then a description, such as â€œUpdates all the software installed by Chocolateyâ€. If your current user account is not an administrator account on your computer, use the Change User or Group button to select an administrator account.
You also need to know the password for the administrator account. Make sure the Run option is selected regardless of whether the user is logged in. This will allow the script to run even if you are not on your computer, and will have all the rights it needs to do the job.
In the Triggers tab, you tell the task when you want to run it. For this, once a week should be enough. In our example, it is set to run every Sunday at 1:00 am. Pick a time when you are unlikely to be using your computer for maximum performance.
It is also recommended that you select the Stop task if it takes longer: check box and change the duration to 2 hours. You can adjust this however you like. To allow the trigger to fire, you must check the Enabled checkbox at the bottom.
Click on the Actions tab and we’ll tell the task what we want it to do. The default action will run the program. This is what we want, so leave it alone. In the Program / Script field, enter powershell.exe. This will let Windows know that you are about to run a PowerShell script.
In the Add arguments box, enter the following arguments.
-noprofile – Prevents PowerShell profile scripts from running and tells it to just run the script you want.
-ExecutionPolicy Bypass – if you are not sure if the execution of the script is allowed, it is good to specify this in the arguments. This will launch the script.
-file is an argument that tells the Task Scheduler that whatever follows is the path to the file that we want PowerShell to run. In our example, the script was saved in C: Scripts upgrade-ChocoPackages.ps1. It may be different on your computer, so set it up accordingly. If your file path contains names with spaces, you need to enclose the entire path in quotes.
The full argument will look like -noprofile -executionpolicy bypass -file C: Scripts upgrade-ChocoPackages.ps1
The Conditions tab has additional options that we can set to run the script. Take a look at them to see which ones you want to apply. In this example, it is set to Run task only if the computer is running on AC power, and Stop if the computer switches to battery power to ensure that the battery is not draining.
Wake up the computer for this task is selected to ensure that the task is completed regardless of whether the computer is in sleep mode or not.
In the Settings tab, it is recommended that you select the Allow the task to run on demand checkbox so that we can manually test the task when it is done. The rest of the options are fine by default.
Click OK to complete the creation of the scheduled task. A window should appear with the name of the user you selected on the General tab. You must enter a password for the user and click OK. This tells Windows that you are indeed allowed to run the task.
You are now returned to the main Task Scheduler window. Find your new challenge. Right-click the task and select Run to test it.
You won’t see anything significant, except that the status of the task changes to In Progress. After about a minute, you should see the last run time also change to the timestamp when you started the task.
If you have not received any error messages, the problem is fine. Close the Task Scheduler window and don’t worry about having to manually update any software you’ve installed with Chocolatey.
everything is okay!
This might seem like a lot of work. Think: it took you 10 to 30 minutes to set up. If you use it to update 10 programs, and each program is updated for 6 minutes every month, you will save 30 to 50 minutes.
You’ve already saved time ahead. This can save 6 to 10 hours of time over the course of a year. That’s not counting the time saved by knowing how to use Chocolatey to install programs in a minute or two instead of 10 or 15 minutes.