def runAsAdmin(cmdLine=None, target_dir='<STR_LIT>', wait=True):
if os.name != '<STR_LIT>':<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>import win32con<EOL>import win32event<EOL>import win32process<EOL>from win32com.shell.shell import ShellExecuteEx<EOL>from win32com.shell import shellcon<EOL>python_exe = sys.executable<EOL>if cmdLine is None:<EOL><INDENT>cmdLine = [python_exe] + sys.argv<EOL><DEDENT>elif type(cmdLine) not in (tuple, list):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>cmd = '<STR_LIT>' % (cmdLine[<NUM_LIT:0>],)<EOL>params = "<STR_LIT:U+0020>".join(['<STR_LIT>' % (x,) for x in cmdLine[<NUM_LIT:1>:]])<EOL>showCmd = win32con.SW_SHOWNORMAL<EOL>lpVerb = '<STR_LIT>'  <EOL>print(target_dir, cmd, params)<EOL>procInfo = ShellExecuteEx(nShow=showCmd,<EOL>fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,<EOL>lpVerb=lpVerb,<EOL>lpFile=cmd,<EOL>lpParameters=params,<EOL>lpDirectory=target_dir)<EOL>if wait:<EOL><INDENT>procHandle = procInfo['<STR_LIT>']<EOL>obj = win32event.WaitForSingleObject(procHandle, win32event.INFINITE)<EOL>rc = win32process.GetExitCodeProcess(procHandle)<EOL><DEDENT>else:<EOL><INDENT>rc = None<EOL><DEDENT>return rc<EOL>
run [cmdLine] as admin
specify the location from where the code is executed through [target_dir]