Skip to content

Instantly share code, notes, and snippets.

@Sepehr0Day
Created April 7, 2024 04:36
UAC Enable/Disable
import winreg
def disable_uac():
try:
# Disabling UAC in Windows can
# expose your system to unauthorized
# access and malware threats.
# Proceed with caution as it compromises
# your system's security.
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", 0, winreg.KEY_WRITE)
winreg.SetValueEx(key, "EnableLUA", 0, winreg.REG_DWORD, 0)
winreg.CloseKey(key)
print("UAC disabled successfully.")
except Exception as e:
print("An error occurred:", e)
def enable_uac():
try:
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", 0, winreg.KEY_WRITE)
winreg.SetValueEx(key, "EnableLUA", 0, winreg.REG_DWORD, 1)
winreg.CloseKey(key)
print("UAC enabled successfully.")
except Exception as e:
print("An error occurred:", e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment