-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_upgrade_winget_noagree.py
More file actions
28 lines (22 loc) · 1.33 KB
/
cli_upgrade_winget_noagree.py
File metadata and controls
28 lines (22 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# CLI Upgrade Script
# Initially written by Jacob F. (https://www.github.com/FiveEyeTea) on 1/5/2026.
# This simple script checks for upgrades with Winget. If it detects any, it will run the full upgrade command.
# NOTE: Winget must be installed and properly set up before using.
# Winget will attempt to upgrade all software on the system, provided it's compatible with Winget.
# Script header
print("CLI Upgrade Script by Jacob F. (https://www.github.com/FiveEyeTea)")
# Initiates the subprocess module for the run statements. Crucial for running all the winget/choco commands.
from asyncio import subprocess
from subprocess import run
# This variable is the command for the initial check. Later in the script, it runs that command and stores a return code that is used to decide if the full upgrade variable will initiate.
winget_check = ["winget", "upgrade"]
# This variable is the upgrade command processe for Winget. Only activates if updates are found.
winget_upgrade = ["winget", "upgrade", "--all"]
# The following print statement is for debugging only: print(winget_check.returncode)
winget_check = run(winget_check, text=True)
if winget_check.returncode == 0:
run(winget_upgrade, text=True)
elif winget_check.returncode == 1:
print("\nNo applicable Winget upgrades found.\n")
else:
print("\nERROR: No return code specified.\n")