PATH debug
This commit is contained in:
@@ -802,7 +802,6 @@ class Ui_DownloadWindow(object):
|
||||
self.logs_box.setPlaceholderText(_translate("MainWindow", "Logs"))
|
||||
|
||||
def popup(title, text):
|
||||
|
||||
QtWidgets.QMessageBox.information(None, title, text)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
# Module for PATH actions
|
||||
import os
|
||||
os.popen('cls')
|
||||
existing_path_value_l = os.popen('PATH').read()[5:].replace('\n', '') # Get the existing path value
|
||||
existing_path_value_s = set()
|
||||
for i in existing_path_value_l.split(';'):
|
||||
existing_path_value_s.add(i + ';')
|
||||
existing_path_value_s = list(existing_path_value_s)
|
||||
existing_path_value_s.sort()
|
||||
existing_path_value = str()
|
||||
for i in existing_path_value_s:
|
||||
existing_path_value += i
|
||||
|
||||
print('Existing path value: ' + existing_path_value)
|
||||
|
||||
|
||||
def add_to_path(program_path: str):
|
||||
import winreg
|
||||
|
||||
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root: # Get the current user's registry
|
||||
with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key: # Open the environment key
|
||||
existing_path_value = os.popen('echo %PATH%').read() # Get the existing path value
|
||||
print(existing_path_value)
|
||||
new_path_value = existing_path_value + ";" + program_path # Connect the new path to the existing path
|
||||
winreg.SetValueEx(key, "PATH", 0, winreg.REG_EXPAND_SZ, new_path_value) # Update the path value
|
||||
|
||||
|
||||
def delete_from_path(program_path: str):
|
||||
import winreg
|
||||
|
||||
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root: # Get the current user's registry
|
||||
with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key: # Open the environment key
|
||||
existing_path_value = os.popen('echo %PATH%').read() # Get the existing path value
|
||||
new_path_value = existing_path_value.replace(program_path + ";", "") # Remove the program path from path
|
||||
new_path_value = existing_path_value + f'{";" if existing_path_value[-1] != ";" else ""}' + \
|
||||
program_path + ';' + program_path + "\\apps;" # Create new
|
||||
print(new_path_value)
|
||||
winreg.SetValueEx(key, "PATH", 0, winreg.REG_EXPAND_SZ, new_path_value) # Update the path value
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user