<<< Back to Search

Misc ::: Start Application as Administrator

Command to start an application/process elevated as administrator.

Snipped and example Open CMD.exe (DOS Window) asynchronously, in a new window, with current user elevated as administrator and execute basic commands.

*User needs to have granted local Admin rights.

Core Snippet

# Misc ::: Start Application as Administrator -_-
# PowerShellExamples.com

$commandToExecute = "echo Begin &amp; dir &amp; echo End - All Files listed above" 
Start-Process -Verb RunAs -FilePath cmd.exe -Args '/k', $commandToExecute


Practical Sample

Copy code below into a power shell session and execute

# Sample : Misc ::: Start Application as Administrator -_-
# PowerShellExamples.com

# Open CMD.exe (DOS Window) as administrator and execute commands
# Start the process asynchronously, in a new window,
# as the current user with elevation (administrative rights).

$commandToExecute = "echo Begin &amp; dir &amp; echo End - All Files listed above" 

# Argument /k leave DOS window open
#          /c close DOS window after execution
Start-Process -Verb RunAs -FilePath cmd.exe -Args '/k', $commandToExecute



Result

==> Open CMD.exe (DOS Window) asynchronously, in a new window, with current user elevated as administrator and execute basic commands.