Run Command Prompt as Administrator by Default on Windows 10

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.)


Solution 1:

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.

Solution 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.

Solution 3:

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