Start a Process Elevated from PowerShell

PowerShell is an advanced form of command prompt. It is extended with a huge set of ready-to-use cmdlets and comes with the ability to use .NET framework/C# in various scenarios. Today, I will show you how to start a process elevated from the PowerShell prompt.


Earlier, I covered how the same can be done from a batch file. However, with Windows 10 Creators Update, Microsoft is going to de-emphasize the command prompt and promote PowerShell everywhere. See these articles for reference:

So, it is a good idea to learn this useful trick which can be performed from the PowerShell console and save your time.

Start a Process Elevated from PowerShell

For this task, we'll use the Start-Process cmdlet. It supports a number of options, one of them is -Verb. If you specify -Verb as "RunAs", the process you are going to start will be opened elevated.

Let's try to launch the Notepad app elevated.

  1. Open PowerShell.
  2. Type or copy-paste the following command:
    Start-Process "notepad.exe" -Verb RunAs

  3. A UAC prompt will appear. Confirm it:
  4. The Notepad app will be opened elevated. You can ensure this using the Task Manager. See the article: How to check if a process is running as administrator (elevated) in Windows

Note: If you press the "No" button at the UAC prompt, the PowerShell console will print out an error message "The operation was canceled by the user.". This is expected.

Tip: You can run an app elevated with the help of PowerShell directly without opening its console first. For example, you can create a shortcut or type the following command in the Run dialog:

powershell.exe -Command "Start-Process Notepad.exe -Verb RunAs"

The result will be the same. The Powershell window will flash for a moment and then the app will be opened elevated.

Start a Process Elevated with Arguments from PowerShell

If you need to pass some arguments (also known as switches or parameters) to a process that you are going to start elevated from PowerShell, use the -Argument switch of the Start-Process cmdlet. Argument specified there will be passed to the target executable file. Here are modified examples with Notepad.exe I used above.

For the PowerShell console, use the following command:

Start-Process "notepad.exe" -Argument "C:\My Stuff\my file.txt" -Verb RunAs

Enclose the paths that have spaces in quotes. If you need to pass more than more argument, separate them with commas and use ArgumentList:

Start-Process "file.exe" -ArgumentList "argument1, argument2, argument3" -Verb RunAs

From within PowerShell, you can use the following command:

powershell.exe -Command "Start-Process 'Notepad.exe' -Argument 'C:\My Stuff\my file.txt' -Verb RunAs"

Yet another example:

powershell -Command "Start-Process powershell.exe -ArgumentList '-ExecutionPolicy Bypass -NoExit -Command \`"Checkpoint-Computer -Description \"RestorePoint1\" -RestorePointType \"MODIFY_SETTINGS\"\`"' -Verb RunAs"

See the article for more information: Create A Restore Point in Windows 10 with PowerShell

Enclose the paths with spaces in single quotes as shown above.
That's it.

One thought on “Start a Process Elevated from PowerShell

  1. Sylvain

    Microsoft wants to impress everyone with the “Verb-Noun” syntax of PowerShell – “It is all standard, no command will ever have totally different parameters like on Unix, bla bla.” And then there is this: -Verb RunAs. Makes absolutely no sense. It’s not -RunElevated, it’s not -RunAsAdmin, or something that would make sense, nope, it’s -Verb RunAs…

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.