import winreg
def disable_startup_program(program_name):
key = winreg.HKEY_CURRENT_USER
key_path = r"Software\Microsoft\Windows\CurrentVersion\Run"
try:
with winreg.OpenKey(key, key_path, 0, winreg.KEY_WRITE) as reg_key:
winreg.DeleteValue(reg_key, program_name)
print(f"Successfully disabled '{program_name}' from startup programs.")
except FileNotFoundError:
print("Unable to find the specified key path.")
except PermissionError:
print("Permission denied to modify the startup programs.")
except Exception as e:
print(f"An error occurred: {str(e)}")
# Provide the program name you want to disable from startup
program_name = "ExampleProgram"
disable_startup_program(program_name)