Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

ctypes run as administrator

import ctypes
import sys
def admin():
    try: return ctypes.windll.shell32.IsUserAnAdmin()
    except Exception: return False
if not admin(): # If not ran as administrator, re-run it as administrator!
    ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
    sys.exit()
 
PREVIOUS NEXT
Tagged: #ctypes #run #administrator
ADD COMMENT
Topic
Name
3+9 =