user3529430 user3529430 - 10 months ago 54
PowerShell Question

How to run cmd as admin and run commands together

I'm looking for a way to be able to open a admin level cmd prompt and then execute a command in that same admin cmd all together in a batch file.

I was trying to fiddle around with:

  • powershell.exe -Command "Start-Process cmd -Verb RunAs"

To do this, but I couldn't figure out a way to send a command to the newly created admin cmd.

What is the best way to achieve this?


You were on the right path, all you needed was the argument -ArgumentList


powershell -Command "Start-Process cmd -Verb RunAs -ArgumentList '/c echo test && pause'"