Run Command Prompt as Administrator by Default on Windows 10

8

After the recent upgrade to Windows 10, the good ol' AppCompatFlags method no longer works. Which is something like this -

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"
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"="~ RUNASADMIN"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Windows\\System32\\cmd.exe"="~ RUNASADMIN"
"C:\\Windows\\SysWOW64\\cmd.exe"="~ RUNASADMIN"
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"="~ RUNASADMIN"

Is there any other way I can make command prompt run as admin by default? I'm not talking about the CTRL + SHIFT + ENTER to run as admin or through a shortcut as they are all very inconvenient.

(E.g. say when you SHIFT right click in a folder and open a new command prompt, it's not gonna run as admin by default and there's no way you can make it run with the privilage without editing the context menu.)

StillAzure

Posted 2015-08-23T16:09:23.217

Reputation: 180

AppCompatFlags > RUNASADMIN still works here, running Win10 1511 10586.218 – w32sh – 2016-04-22T11:29:03.357

Odd, is it the same exact path and key? It's not working here. – StillAzure – 2016-04-22T11:31:20.673

Yes. I used your REG file infact. – w32sh – 2016-04-22T17:20:44.580

Does running this command show any integrity violation for sysmain.sdb?

sfc /verifyfile=C:\windows\AppPatch\sysmain.sdb – w32sh – 2016-04-22T17:36:09.820

Nope, by the way this was tested on multiple fresh installment of Windows 10. All latest builds. – StillAzure – 2016-04-23T03:31:15.673

Not much ideas then... except checking the Services configuration Defaults are listed here and doing a clean boot to test.

– w32sh – 2016-04-23T04:31:17.993

Pretty much the same, this is odd. – StillAzure – 2016-04-25T01:39:55.243

Possibly the results differ according to whether it's a standard user seeking ordinary admin privileges, or an admin user seeking elevated (i.e., built-in Administrator) privileges. In the latter context, this didn't work for me. – Ray Woodcock – 2019-10-20T21:31:19.777

Answers

6

STEP 1

Open the Start menu and click All apps find the program you want to always run in administrator mode and right-click on the shortcut. Click the Open file location (only desktop programs will have this option)

screenshot of start menu

STEP 2

A File Explorer window will open to the location of the program you want to access.

Right-click on the program and click Properties from the pop-up menu.

menu screenshot

STEP 3

In the Properties window, click the Shortcut tab and then click Advanced

screenshot

Step 4

In the Advanced Properties window, check the box next to Run as administrator and click OK.

screenshot

The program will now open in administrator mode.

vembutech

Posted 2015-08-23T16:09:23.217

Reputation: 5 693

2That won't work if you run Command Prompt from Run though, which is what I use often. – StillAzure – 2016-02-10T15:12:46.023

@StillAzure I have spent like 2h just looking on how to make this work. Here is the solution - make it as in the answer above, create a shortcut of that .exe . Change that shortcut to whatever command you like to enter in run - for me I set it up as cmda - command prompt admin. Move it to C:\Windows folder. Now you can run it easily. – Candid Moon _Max_ – 2017-11-20T00:02:36.573

1@CandidMoon It would still kinda be a botched solution, but better than nothing :p – StillAzure – 2017-11-20T04:17:39.160

2

Actually, there is a way to do it:

  1. You need to go to C:\WINDOWS\system32\ and take ownership over cmd.exe. You can do it by Right click->Properties->Security->Advanced->Change (in blue with the shield icon).
  2. Now you can give yourself access to modify it, or whatever you need to rename it.
  3. Once you've done that, rename it to whatever you like.
  4. You can access it's compatibility properties tab and tick "Run as administrator"

Voila! Done!

But, not quite, no program will now be able to find cmd.exe since it no longer exists. But fret not, open your shiny new renamed cmd and run this command:

mklink "C:\WINDOWS\system32\cmd.exe" "C:\WINDOWS\system32\cmdWithNewName.exe"

Congrats, you now have a dummy cmd.exe that will point to your renamed exe that is always ran as administrator.

Remember to change the permissions on the new "cmdWithNewName.exe" back to being only read & execute. After you've done that, you can change the owner of the file back to TrustedInstaller by entering "NT SERVICE\TrustedInstaller" in the object name field where you originally took ownership of the file.

This locks the file from any further tampering, lessening the security risk.

Karlovsky120

Posted 2015-08-23T16:09:23.217

Reputation: 177

1

After following the instructions above, making the program start in administrator mode by default, I added a shortcut key, CTRL + ALT + E to the properties options, works great.

enter image description here

Chris Quinn

Posted 2015-08-23T16:09:23.217

Reputation: 11

-3

If you are using Windows 10 File explorer, click on "File" (left top corner) & mouse over "Open Command Prompt". There is an option to run as administrator.

Dave_cz

Posted 2015-08-23T16:09:23.217

Reputation: 147

Welcome to Super User! Have another look at the OP's question. He wants to configure the Command Prompt so that it runs as Admin by default. Please revisit your answer accordingly. Thanks for contributing. – I say Reinstate Monica – 2015-08-24T21:29:21.943

1and there's an easier way in windows 10: press win+X – phuclv – 2017-01-05T07:01:00.970

@phuclv, whoa, that's pretty cool – brgs – 2018-08-12T15:49:35.923

-4

There is another seemingly easier way to achieve this. You can just disable UAC (User Access Control) which was formerly known as LUA (Limited User Account). Beware that you are disabling UAC. It should not be a problem if you know what you are doing (since most of us here are developers, this should be no problem)

  1. Open regedit (Run->regedit)

  2. Navigate to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

  3. Change the value of EnableLUA to 0

  4. Apply and reboot the PC

The next time you launch cmd using Run, it will be invoked with admin rights.

Muthu Narayanan

Posted 2015-08-23T16:09:23.217

Reputation: 1

Disabling UAC does not run things with admin by default as far as I know. – StillAzure – 2020-01-21T17:25:05.573