0

I am currently using the subprocess package to execute the commands in powershell through python with the following:

subprocess.run(['pwsh', '-Command', 'my command'])

This is working without any privilege escalation as admin.

Now, I want to run with privilege escalation.

Can someone help me to achieve this step.

ISK2022
  • 1
  • 1
  • Would this help? https://stackoverflow.com/questions/19672352/how-to-run-script-with-elevated-privilege-on-windows – rabbibillclinton Jun 22 '22 at 03:54
  • one simple solution is first running python as administrator - sub processes will inherit elevated privileges – Cpt.Whale Jun 22 '22 at 15:08
  • @Cpt.Whale subprocess will inherit elevated privileges, even if the UAC asks for the admin credentials instead of yes/no while elevating the privileges? – ISK2022 Jun 24 '22 at 10:51
  • @ISK2022 Yes, there is no real difference between the two (You'll see the yes/no prompt if your current user can elevate, but current process is not elevated). The subprocess should inherit the privilege level unless you really go out of your way to run the subprocess as another user or something – Cpt.Whale Jun 24 '22 at 17:03

0 Answers0