How to open an elevated cmd using command line for Windows? How to open an elevated cmd using command line for Windows? windows windows

How to open an elevated cmd using command line for Windows?


I ran into the same problem and the only way I was able to open the CMD as administrator from CMD was doing the following:

  1. Open CMD
  2. Write powershell -Command "Start-Process cmd -Verb RunAs" and press Enter
  3. A pop-up window will appear asking to open a CMD as administrator


I don't have enough reputation to add a comment to the top answer, but with the power of aliases you can get away with just typing the following:

powershell "start cmd -v runAs"

This is just a shorter version of user3018703 excellent solution:

powershell -Command "Start-Process cmd -Verb RunAs"


According to documentation, the Windows security model...

does not grant administrative privileges at all times. Even administrators run under standard privileges when they perform non-administrative tasks that do not require elevated privileges.

You have the Create this task with administrative privileges option in the Create new task dialog (Task Manager > File > Run new task), but there is no built-in way to effectively elevate privileges using the command line.

However, there are some third party tools (internally relying on Windows APIs) you can use to elevate privileges from the command line:

NirCmd:

  1. Download it and unzip it.
  2. nircmdc elevate cmd

windosu:

  1. Install it: npm install -g windosu (requires node.js installed)
  2. sudo cmd