Reputation: 31
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:
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?
Upvotes: 0
Views: 561
Reputation: 4173
You were on the right path, all you needed was the argument -ArgumentList
Example:
powershell -Command "Start-Process cmd -Verb RunAs -ArgumentList '/c echo test && pause'"
Upvotes: 2