I want to execute installation command as an admin via subprocess. How can I run command as an admin? Here what I have so far:
import subprocess subprocess.
Try:
import os subprocess os.chdir("C:\\Users\\user\\") cmd= subprocess.Popen(["runas", "/noprofile", "/user:Administrator", "|", "echo", "Y", "|", "choco", "install", "dropbox"],stdin=sp.PIPE) cmd.stdin.write('password') cmd.communicate()