1import os
2import sys
3import win32com.shell.shell as shell
4ASADMIN = 'asadmin'
5
6if sys.argv[-1] != ASADMIN:
7 script = os.path.abspath(sys.argv[0])
8 params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
9 shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable, lpParameters=params)
10 sys.exit(0)