Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As a developer, I often have the need to open a command prompt for various purposes. For example, I use iisreset to restart my local web server.

I typically open the command window in one of two ways:

  1. Press Win, type "cmd" and press Enter
  2. While in Explorer, hold Shift and right click on a folder, and choose "Open command window here"

However, when I open the command window in either of these ways, I do not have the full administrator privileges that I feel I am entitled to.

I am an administrator, but cmd.exe doesn't know that

In order to run administrator-only applications, I have to open the command line in this relatively laborious way:

  1. Press Win, type "cmd"
  2. Wait for the menu to populate
  3. Lift hand off the keyboard and put it on the mouse
  4. Right click the "cmd.exe" menu item
  5. Choose "Run as administrator"

This is unacceptable for several reasons:

  • The window always opens in C:\windows\system32, rather than my Users directory (as in approved technique 1) or the folder I want to be in (as in approved technique 2). So I often have to change directories to get where I want to go.
  • This process is several milliseconds slower than either of my preferred methods. Performed several times a day, every day for the remainder of my career, it adds up to about ten days of lost time spent clicking and waiting and directory changing.
  • As a programmer, performing a pointless robotic task causes me great emotional pain.
  • As a programmer, lifting my hand is a strenuous task that causes me great physical pain.

That is why I am looking for a one-and-done solution that will let approved techniques 1 & 2 open administrator command prompts.

Many programs let you permanently change their default privilege level from the Properties menu. Command Prompt is not one of those programs.

enter image description here

How do I make the command window run as administrator by default (even when using the "Open command window here" context menu option)?

share|improve this question
Why not just change UAC to elevate only? –  surfasb Jul 26 '12 at 2:46
I don't see an "elevate only" option on my UAC slider. Are you referring to something besides the User Account Control Settings window? –  Kevin Jul 26 '12 at 11:37
I think its Hammer Time... –  Nathan Taylor Sep 23 '14 at 8:42

15 Answers 15

up vote 53 down vote accepted

To answer the first part of your question, when you hit the Windows key and type "CMD" you can hit Ctrl + Shift + Enter to open as administrator.

To answer the second part of your question, paste the following into notepad and save it with a ".reg" extension:

Windows Registry Editor Version 5.00

@="Open Command Window Here as Administrator"

@="cmd.exe /s /k pushd \"%V\""

Then run the file. It will merge the changes into the registry and add the option to your context menus. (No shift key needed.)

share|improve this answer
Note; you will still have to accept the UAC prompt in both cases. –  Synetech Jul 25 '12 at 17:17
Registry edit doesnt work in windows 8. –  Biker John Aug 1 '14 at 11:50
Registry patch works for Server 2012 R2 –  fiat Aug 21 '14 at 0:51

Many programs let you permanently change their default privilege level from the Properties menu. Command Prompt is not one of those programs.

The Compatibility tab is completely disabled for all of Windows’ executables:

enter image description here

To set admin privileges for Windows executables, you need to create a shortcut and use Shortcut tab→Advanced (the command-prompt item in the Start menu is already a shortcut):

enter image description here

The window always opens in C:\windows\system32, rather than my Users directory (as in approved technique 1) or the folder I want to be in (as in approved technique 2). So I often have to change directories to get where I want to go.

That is normal and makes sense since if you are opening an admin command-prompt, you are probably doing some system actions for which you need admin privileges instead of user actions that you already have permissions for anyway.

You can set the default directory globally by adding/editing the Autorun registry entry (it does not even have to be an expandable string to use environment variables):

[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"Autorun"="cd /d \"%userprofile%\""

Now, any time you open a command-prompt using any method will automatically default (well, technically change-directory) to your user-profile directory.

Even better, you can add other commands to be automatically run whenever you open a command-prompt using the & operator (e.g., cd /d %userprofile% & cls & dir). In addition, you can set the same value in the same key under the HKLM branch to set it for all users.

Note that you will still have to accept the UAC prompt. Unfortunately there is (currently?) no way to create a UAC “whitelist” of trusted programs so that the command-prompt can be run as admin without having to accept the prompt. This leaves you with (a) few options.

  • You can turn UAC down or off altogether (useraccountcontrolsettings.exe)
  • You can use a privilege-elevation program like Elevator aka Elevate Me or the Elevation PowerToy
  • Create an elevated scheduled task, enter the credentials (once) for it, and then create a shortcut to the task

In the first case, you avoid the UAC altogether while in the latter two, you only enter your credentials once when creating the shortcut.

share|improve this answer

The solution I use is to open command prompt by opening start menu, typing 'cmd' and pressing Ctrl+Shift+Enter. This will cause the selected program to be launched as administrator.

share|improve this answer
Is there an alternative that doesn't require "search" ? (because from what I know typing stuff in the box actually does searching) –  Pacerier Nov 13 '11 at 12:36
Only other way I know is Luke's answer, disable UAC. The searching for cmd is pretty fast, can't even manage to hit Ctrl+Shift+Enter before it finds it. –  Dracs Nov 13 '11 at 12:45
I do that all the time on customer computers. It finds CMD pretty damn fast –  Canadian Luke Nov 13 '11 at 18:04
Will this load it as Administrator? –  barlop Nov 13 '11 at 20:28
@barlop Yes, that hotkey (Ctrl+Shift+Enter) will launch the highlighted program in the Start menu as administrator. –  Dracs Nov 13 '11 at 22:01

To auto run CMD as admin each time it is simply clicked (without having to right-click or create additional shortcuts), there is an easy fix for this:

In the registry editor, navigate to "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" (If there isn't a Layers folder, you'll have to create one) For the value, make it the full path to command prompt. (i.e. C:\Windows\System32\cmd.exe and without quotes) and the data of that value "RUNASADMIN" without quotes.

I had this same annoyance, and it worked for me.

share|improve this answer

There have been a couple tools that I've used that were other workarounds (in addition to what Jesse mentioned).

Back when Vista first came out, Microsoft came out with an "elevate" powerToy that was quite useful and did the job and still, I believe (haven't tested) works for Windows 7. Drop it into your path environment and you could run "elevate iisreset" from a normal command prompt (or even "elevate cmd" from the start/run or a create a shortcut)

share|improve this answer

Just copy & paste cmd.exe and rename it as "cmda.exe" in \system32\ folder (337 KB isn't even a big deal...). The "run as administrator" option in cmda.exe's properties will no longer grayed out and you can set it to always run as admin. You'll now have two command prompts: first one is regular, 2nd one has an (a)dmin privilege. It's as easy to type "cmda" in Win search bar as you do with "cmd"!

For the cmd in context menu with admin privilege, ensure that you already have cmda.exe in place, add this into new .reg file & launch it

Windows Registry Editor Version 5.00

@="Open command window here (Administrator)"

@="cmda.exe /s /k pushd \"%V\""

You will see two same lines in context menu (shift); one non-elevated Command Prompt and another one with "(Administrator)" added in.

That's it...

share|improve this answer

The easiest way to bypass all the grief of UAC etc is to setup a Task Schedule entry to run cmd.exe using the highest privileges. Do not create a Trigger event for it and make sure that the Allow Task To Be Run On Demand check box is selected in the Settings tab. Also in the Settings tab make sure that the "If The Task Is Already Running, Then The Following Rule Applies" drop down is set to Do Not Start A New Instance.

Then create a shortcut to this on your desktop and run it from there, or via a shortcut hotkey or pin the shortcut to the Task bar.

I have done it on my Windows 7 system and it works perfectly.

share|improve this answer
Oops, I forgot to specify one important thing. Here is the target path for the shortcut to the Task. C:\Windows\System32\schtasks.exe /run /TN "command prompt without UAC". The text inside the quotes is whatever you name the Task when you create the Task. –  Peter Wills Sep 25 '13 at 1:36
don't enclose your email id in your answers –  BlueBerry - vignesh4303 Sep 25 '13 at 4:07

The only other way, other than what Dracs mentioned, is to disable UAC completely

share|improve this answer

Create a shortcut to cmd.exe, right click and select properties, on the Shortcut tab select Advanced, check Run as Administrator.

share|improve this answer

I think the easiest way to always run cmd as admin is to make the .reg file with the code below:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]

Paste that in notepad or something and save as .reg file. Note: This makes command prompt run as admin for all users. To always run as admin only on your user just change HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER

share|improve this answer

If you want CMD.exe be always run as administrator, just add bellow reg code to your Registry:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Windows\\System32\\cmd.exe"="~ RUNASADMIN"
"C:\\Windows\\SysWOW64\\cmd.exe"="~ RUNASADMIN"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Windows\\System32\\cmd.exe"="~ RUNASADMIN"
"C:\\Windows\\SysWOW64\\cmd.exe"="~ RUNASADMIN"
share|improve this answer

I don't have enough reputation to upvote T.T but Blue's suggestion is by far the best for me, as I open command prompt by a widget or Win-R. (The Task Scheduler method is the best for Start Menu users as it bypasses UAC altogether. However, I am on an administrator account, and don't have to fill in my password, so UAC doesn't bug me.)

A simpler way to implement this would be to make a new text document, paste

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers] "C:\Windows\System32\cmd.exe"="RUNASADMIN"

and then change the extension to .reg.

share|improve this answer


Pls correct syntax of path in the reg file code. There should be two '\' instead of one. That is the correct syntax is:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers] "C:\\Windows\\System32\\cmd.exe"="RUNASADMIN"

Also if you want to make this change to all users, change "HKEY_CURRENT_USER" to "HKEY_LOCAL_MACHINE".

Update: I figured out that on publishing reply the double "\" sign in code shows as single one. So I replaced double "\" with triple and now it shows correctly after publishing.

share|improve this answer

The following works for me

@echo off :: BatchGotAdmin :------------------------------------- REM --> Check for permissions

nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin )

:UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

exit /B

:gotAdmin if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) pushd "%CD%" CD /D "%~dp0" :--------------------------------------

you will get the same uac prompt confirming to runas admin.. found it some time ago @ stackexchange

share|improve this answer

All thanks to Jesse Brohinsky

A more improved version. This also includes the background directory that enables you to opencmd from inside the folder aswell. Also for the sake of it you can open the commandpromt as non admin.

Also you can disable AdminApprovalMode. This way you dont need to run as admin when you are admin. http://helpdeskgeek.com/windows-7/turn-off-admin-approval-mode-in-windows-7/

Windows Registry Editor Version 5.00
;write minus before to unreg example: [-HKEY_CLASSES_ROOT\Directory\shell\cmdhere]

@="Open Command Window Here"

@="cmd.exe /s /k pushd \"%V\""

@="Open Command Window Here"

@="cmd.exe /s /k pushd \"%V\""

@="Open Command Window Here as Administrator"

@="cmd.exe /s /k pushd \"%V\""

@="Open Command Window Here as Administrator"

@="cmd.exe /s /k pushd \"%V\""
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.