-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from grubyhs/feature/placzykowski/move-winget-a…
…nd-windows-update-to-seperate-py seperate windows update and winget py
- Loading branch information
Showing
5 changed files
with
35 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import subprocess | ||
|
||
def windows_update(): | ||
try: | ||
print("Checking for Windows updates...") | ||
|
||
# Install the PSWindowsUpdate module if not already installed | ||
ps_install_command = ( | ||
"Install-Module PSWindowsUpdate -Force -AllowClobber -Scope AllUsers; " | ||
"Set-ExecutionPolicy Bypass -Scope Process -Force; " | ||
"Import-Module PSWindowsUpdate -Force;" | ||
"$serviceManager = New-Object -ComObject 'Microsoft.Update.ServiceManager';" | ||
"$serviceManager.AddService2('7971f918-a847-4430-9279-4a52d1efe18d',7,'');" | ||
"Install-WindowsUpdate -AcceptAll -AutoReboot -IgnoreUserInput;" | ||
) | ||
|
||
subprocess.run(["powershell", "-ExecutionPolicy", "Bypass", "-Command", ps_install_command], check=True) | ||
|
||
print("Windows updates checked and installed successfully.") | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error checking or installing Windows updates: {e}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import subprocess | ||
|
||
def winget_upgrade(): | ||
# Upgrade all installed packages using winget | ||
try: | ||
subprocess.run(["winget", "upgrade", "--all", "--accept-source-agreements", "--accept-package-agreements", "--allow-reboot"], check=True,) | ||
print("All installed packages upgraded successfully.") | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error upgrading packages with winget: {e}") |