I have to create a new process with Admin privileges using a python script. I searched on the Internet about this topic and found out that I have to use runas
command. For this command, I have to give an user and at runtime, the script will wait for the password and I want to do this as automatic as possible.
This is my code:
import subprocess
p = subprocess.Popen(['runas', '/user:Armando', szCmdCommand], stdin = subprocess.PIPE)
p.stdin.write('password')
Instead of .write
I tried p.communicate(input='password')
but it isn't working because it doesnt write the password. The only thing that happens is that the script doesn't wait for input. It automatically takes a wrong password and fails the execution of my command.
What can I do to fix this?