Skip to content

Dear Internet Explorer user: Your browser is no longer supported

Please switch to a modern browser such as Microsoft Edge, Mozilla Firefox or Google Chrome to view this website's content.

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.

Winget in Windows Terminal updating apps on Windows 11.

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\.

The creation of a batch file in Visual Studio Code. You can also use Notepad for this task.

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.

Winget updating software after a Batch file was Run as Administrator.

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… .

Windows Task Scheduler: Click on Task Scheduler Library, then Create Task…

Under the General tab:

  1. Give the task a Name (“Winget Update”)
  2. Give the task a Description (optional)
  3. Choose Run only when user is logged on
  4. Choose Run with highest privelleges
The General tab in Create Task.

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

Then:

  1. Begin the task On a schedule
  2. Choose Daily
  3. Set a time
  4. Set the task to Recur every 1 days
  5. Ensure that Enabled is ticked
The Trigger window in Windows Task Scheduler

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

The Actions tab specifies where the script is.

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.

Manually triggering the task in Task Scheduler.

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

The Command Prompt will execute the Winget code when the Task is triggered.
   

Comments

No comments have yet been submitted. Be the first!

Have Your Say

The following HTML is permitted:
<a href="" title=""> <b> <blockquote cite=""> <code> <em> <i> <q cite=""> <strike> <strong>

Comments will be published subject to the Editorial Policy.