I have this code:
command = "runas /user:theuser cmd"
subprocess.run(command)
and here cmd asks for password to theuser My question is if I can enter the password here using python?
You should use subprocess.Popen
instead. This means you can communicate with the program:
command = "runas /user:theuser cmd"
p = Popen([command], stdout=PIPE, stdin=PIPE, stderr=PIPE)
p.communicate(input='data')[0]
You can check out The docs for more info
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.