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"

Simple way I did after trying other answers here

Method 1: WITHOUT a 3rd party program (I used this)

  1. Create a file called sudo.bat (you can replace sudo with any name you want) with following content powershell.exe -Command "Start-Process cmd \"/k cd /d %cd%\" -Verb RunAs"
  2. Move sudo.bat to a folder in your PATH; if you don't know what that means, just move these files to c:\windows\
  3. Now sudo will work in Run dialog (win+r) or in explorer address bar (this is the best part :))

Method 2: WITH a 3rd party program

  1. Download NirCmd and unzip it.
  2. Create a file called sudo.bat (you can replace sudo with any name you want) with following content nircmdc elevate cmd /k "cd /d %cd%"
  3. Move nircmdc.exe and sudo.bat to a folder in your PATH; if you don't know what that means, just move these files to c:\windows\
  4. Now sudo will work in Run dialog (win+r) or in explorer address bar (this is the best part :))

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