open administrator command prompt using python

Solutions on MaxInterview for open administrator command prompt using python by the best coders in the world

showing results for - "open administrator command prompt using python"
Jeremiah
30 Jun 2019
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)