It's a little roundabout, but another way is to run a shell command, launch Powershell (comes with Windows), then tell Powershell to run the .exe as Admin:
(just remember that the shell command is in CMD, so you escape with backslash, not Powershell's backtick.)
Powershell command:
Start-Process "executable.exe" -ArgumentList @("Arg1", "Arg2") -Verb RunAs
CMD running Powershell:
Powershell -Command "& { Start-Process \"executable.exe\" ... }"
Python running CMD runnning Powershell:
os.system(r'''
Powershell -Command "& { Start-Process \"notepad.exe\"
-ArgumentList @(\"C:\\Windows\\System32\\drivers\\etc\\hosts\")
-Verb RunAs } " '''
stdinPIPE to send it, but then you need to store it somehow accessible to your Python script. That looks likeproc = subprocess.call(['runas','/user:Administrator','myfile.exe'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)Then you could doproc.stdin.write('password\r\n'). – nerdwaller Jul 04 '13 at 18:28