Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have a problem with starting an .exe.exe file as administrator rights..

I also tried:['runas', '/user:Administrator', 'myfile.exe'])

But then i have to enter a password..

Is there any chance to leave that out?


PS: I searched now for some hours... didn't find anything!

share|improve this question
Why would you remove the password? – Diblo Dk Jul 4 '13 at 18:25
You could use an stdin PIPE to send it, but then you need to store it somehow accessible to your Python script. That looks like proc =['runas','/user:Administrator','myfile.exe'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) Then you could do proc.stdin.write('password\r\n'). – nerdwaller Jul 4 '13 at 18:28
@nerdwaller, I'm trying this for a while but without success. Are you sure this works? – McLeary Feb 11 '14 at 0:30
up vote 1 down vote accepted

The only way I know from what you say, is to use "Application Compatibility Toolkit"

And how to use it:

Source: Can you turn off UAC for a single app?

share|improve this answer
Thanks alot, it worked :) – Astraioz Jul 4 '13 at 20:17

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:
Powershell -Command "& { Start-Process \"notepad.exe\"
 -ArgumentList @(\"C:\\Windows\\System32\\drivers\\etc\\hosts\")
 -Verb RunAs } " '''
share|improve this answer

I realise I'm coming in late on this and it may not be a really elegant solution....but if you open an elevated command prompt and then launched your python script, would the executables called with "" not be launched with the same elevation as the CMD window?

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .