Automate Windows app updates with Winget
Combine command-line simplicity with a batch script and Windows Task Scheduler to automate the update of Windows apps.
Updating apps with Windows Package Manager (Winget) is easy, but once the updates start rolling in, the numerous commands can become combersome too.
It is possible to update all apps in Windows with a single command. To do this, open Windows Terminal (or the Command Prompt) as administrator, then enter the following command:
winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown
This will prevent the UAC admin prompt from executing for each app, and the task will work in the background.

Taking it to the Next Level
Within Windows, it is possible to automate this process entirely, using the Windows Task Scheduler and a batch file.
Open a plain-text editor such as Visual Studio Code or Notepad and create a file called winget_update.bat. In it, add the following code:
winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown
Save to c:\users\<your_user_id>\Scripts\.

To test that it works, locate the new batch file in Windows Explorer, right-click on it and select Run as Administrator… . If the batch file works, the Command Prompt (not Windows Terminal) will launch and will start the update process after you accept a single UAT prompt.

Full Automation
The next step is to get Windows Task Scheduler to automate this process. To initiate this process, open Task Scheduler, then click on Task Scheduler Library and then Create Task… .

Under the General tab:
- Give the task a Name (“Winget Update”)
- Give the task a Description (optional)
- Choose Run only when user is logged on
- Choose Run with highest privelleges

Next, switch to the Triggers tab and click on New…

Then:
- Begin the task On a schedule
- Choose Daily
- Set a time
- Set the task to Recur every 1 days
- Ensure that Enabled is ticked

Next, click on the Actions tab. Choose Start a program as the Action, and then link to the bat file created earlier.

On the Settings tab, the defaults will suffice. Save the new task.
Checking that it Works
To check that your new task works, click on it in the Task Scheduler and then select Run. The script should execute.

If everything works as it should, the Command Prompt should come up and all of the software that needs updating will be updated.

Comments
No comments have yet been submitted. Be the first!