Skip to content

Commit

Permalink
Merge pull request #3 from grubyhs/feature/placzykowski/add-motherboa…
Browse files Browse the repository at this point in the history
…rd-function

Add MSI Center support
  • Loading branch information
piotrlaczykowski authored Jun 9, 2024
2 parents 823090b + 07cf3af commit 6e6bb4f
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 21 deletions.
19 changes: 9 additions & 10 deletions dell.py → dell_support_assist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import subprocess
import winreg
from utilities import *
from motherboard import *

# Define the URL to download Dell SupportAssist
support_assist_download_url = "https://downloads.dell.com/serviceability/catalog/SupportAssistInstaller.exe"

# Set the installer path to the specified download folder
user_download_folder = os.path.join(os.path.expanduser("~"), "Downloads")
dell_support_assist_installer_filename = "SupportAssistInstaller.exe"
support_assist_installer_path = os.path.join(user_download_folder, dell_support_assist_installer_filename)
support_assist_installer_path = os.path.join(user_download_folder(), dell_support_assist_installer_filename)

def launch_dell_support_assist():
try:
Expand All @@ -25,18 +25,17 @@ def launch_dell_support_assist():
print(f"Error launching the UWP app: {e}")

def install_support_assist():
download_installer(url=support_assist_download_url, user_download_folder=user_download_folder,installer_path=support_assist_installer_path)
download_installer(url=support_assist_download_url, user_download_folder=user_download_folder(),installer_path=support_assist_installer_path)
# Install Dell SupportAssist
install_program(support_assist_installer_path)
install_program(support_assist_installer_path, "Dell Support Assist")

# Check if Dell SupportAssist is already installed
def check_and_launch_dell_support_assist():
if "Dell" in mobo_manufacturer():
try:
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Dell\SupportAssistAgent", 0, winreg.KEY_READ):
launch_dell_support_assist()
except FileNotFoundError:
install_support_assist()
try:
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Dell\SupportAssistAgent", 0, winreg.KEY_READ):
launch_dell_support_assist()
except FileNotFoundError:
install_support_assist()

def dell():
print(mobo_manufacturer())
Expand Down
12 changes: 12 additions & 0 deletions motherboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from dell_support_assist import *
from msi import *
from utilities import *


def motherboard_launcher():
motherboard = mobo_manufacturer()
if "Dell" in motherboard:
dell()
elif "Micro-Star" in motherboard:
msi()

61 changes: 61 additions & 0 deletions msi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from utilities import *
import glob

# Define the URL to download MSI Center
msi_center_download_url = "https://download.msi.com/uti_exe/desktop/MSI-Center.zip"
msi_center_assist_zip_filename = "MSI-Center.zip"
msi_center_zip_path = os.path.join(user_download_folder(), msi_center_assist_zip_filename)
# Set the installer path to the specified download folder
def is_msi_center_installed():
cmd = 'powershell "Get-AppxPackage -AllUsers | Where-Object {$_.Name -like \'*MSICenter*\' -or $_.Name -like \'*MSIcenter*\' -or $_.Name -like \'*MSI center*\'}"'
result = subprocess.run(cmd, capture_output=True, text=True, shell=True)
return 'MSICenter' in result.stdout or 'MSIcenter' in result.stdout or 'MSI center' in result.stdout

def install_msi_center():
# Download and unzip the installer
download_installer(msi_center_download_url, user_download_folder(), msi_center_zip_path)
msi_unzip_folder = os.path.join(user_download_folder(), "MSI-Center")
unzip(msi_center_zip_path, msi_unzip_folder)

# Now that the .exe file has been unzipped, we can find its path
msi_center_exe = glob.glob(os.path.join(msi_unzip_folder, "MSI Center*.exe"))[0]
if msi_center_exe:
program_name = "MSI Center"
if os.path.exists(msi_center_exe):
try:
subprocess.run([msi_center_exe, "/SILENT"], check=True)
print(f"{program_name} installed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error installing {program_name}: {e}")
else:
print("Error: Installer not found.")
else:
print("No MSI Center installer found in the download folder.")


def launch_msi_center():
try:
ps_command = (
"Get-AppxPackage | Where-Object {$_.Name -like '*MSICenter*'} | "
"Foreach-Object {"
"$packageName = $_.PackageFamilyName;"
"Start-Process shell:AppsFolder\\$packageName!App;"
"}"
)
subprocess.run(["powershell", "-Command", ps_command], check=True)
except subprocess.CalledProcessError as e:
print(f"Error launching the UWP app: {e}")


# Check if MSI Center is already installed
def check_and_launch_msi_center():
if is_msi_center_installed():
launch_msi_center()
if not is_msi_center_installed():
install_msi_center()
launch_msi_center()


def msi():
print(mobo_manufacturer())
check_and_launch_msi_center()
4 changes: 2 additions & 2 deletions update-pc-script-auto.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import sys
from utilities import *
from dell import *
from motherboard import *

if __name__ == "__main__":
if run_as_admin():
dell()
motherboard_launcher()
# Update Winget
winget_upgrade()
# Check if Chocolatey (choco) is installed and perform the necessary actions
Expand Down
9 changes: 4 additions & 5 deletions update-pc-script.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import sys
from motherboard import *
from utilities import *
from dell import *

if __name__ == "__main__":
if run_as_admin():
try:
update_choice = display_update_menu()
if (update_choice == 1 or update_choice == 5):
dell()
if update_choice == 1 or update_choice == 5:
motherboard_launcher()
# Update Winget
# Check if the user needs to accept terms for using winget
if update_choice == 2 or update_choice == 5:
Expand All @@ -28,4 +27,4 @@
print(f"An error occurred: {str(e)}")
input("Press Enter to exit...")
else:
sys.exit(0) # Exit if user declines admin privileges
sys.exit(0)
17 changes: 13 additions & 4 deletions utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import subprocess
import requests
import wmi
import zipfile

# Function to display the update menu
def display_update_menu():
print("Select an option to update:")
print("1. Dell Support Assist")
print("1. Launch/Install Motherboard Manufacturer Software")
print("2. Winget Update")
print("3. Choco Update")
print("4. Windows Update")
Expand All @@ -19,6 +20,14 @@ def display_update_menu():
return int(choice)
else:
print("Invalid choice. Please enter a valid option.")

def user_download_folder():
user_download_folder = os.path.join(os.path.expanduser("~"), "Downloads")
return user_download_folder

def unzip(file_name_to_unzip, unzip_destination):
with zipfile.ZipFile(file_name_to_unzip,"r") as zip_ref:
zip_ref.extractall(unzip_destination)

def mobo_manufacturer():
motherboard = wmi.WMI().Win32_ComputerSystem()[0].Manufacturer
Expand Down Expand Up @@ -81,13 +90,13 @@ def unsecured_download_installer(url, user_download_folder, installer_path):
except requests.exceptions.RequestException as e:
print(f"Request error: {e}")

def install_program(installer_path):
def install_program(installer_path, program_name):
if os.path.exists(installer_path):
try:
subprocess.run([installer_path], check=True)
print("Dell SupportAssist installed successfully.")
print(f"{program_name} installed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error installing Dell SupportAssist: {e}")
print(f"Error installing {program_name}: {e}")
else:
print("Error: Installer not found.")

Expand Down

0 comments on commit 6e6bb4f

Please sign in to comment.