Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I also tried:

subprocess.call(['runas', '/user:Administrator', 'myfile.exe'])

But then i have to enter a password..

Is there any chance to leave that out?

Thanks!

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 = subprocess.call(['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 at 0:30

2 Answers 2

up vote 1 down vote accepted

The only way I know from what you say, is to use "Application Compatibility Toolkit" http://www.microsoft.com/downloads/details.aspx?FamilyId=24DA89E9-B581-47B0-B45E-492DD6DA2971&displaylang=en

And how to use it: http://blogs.techrepublic.com.com/window-on-windows/?p=635

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.