if sys.argv[-1] != ASADMIN:
    script = os.path.abspath(sys.argv[0])
params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable, lpParameters=params
    )
Request UAC elevation from within a Python script?