18

I don't want to install PowerToys, I'd rather a simpler solution for this specific problem.

I've tried Ctrl+Shift+Right-Click.

I've tried adding a registry script, but I get the following error:

Cannot import D:\Admin\Reg\Open command window here (Administrator)\Open command window here (Administrator).reg: The specified file is not a registry script. You can only import binary registry files from within the registry editor.

Any suggestions?

Edit:

Forgot to mention: I've tried the import facility in regedit to no avail

0

8 Answers 8

25

This is one of my favorites, It also takes a bit of work.

1.- Create a file.txt

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Directory\shell\runas]

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="ElevatedCMD"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="ElevatedCMD"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

[-HKEY_CLASSES_ROOT\Drive\shell\runas]

[HKEY_CLASSES_ROOT\Drive\shell\runas]
@="ElevatedCMD"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell]
@="none"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas]
@="ElevatedCMD"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

2.- Rename the file.txt to file.reg

3.- Click in file.reg

It'll create a regular right click context menu for most if not all possible menus.

4.- Accept confirm authorization about it.

5.- Enjoiy it

Note: Change the text "ElevatedCMD" to whatever you want, this text will be displayed to execute the CMD, and if you added it and wants to change the text, only search in regedit, open it with Windows+R and type regedit and Enter, the regedit will open, search "ElevatedCMD" with ctrl+B(Finder) and F3(Next) and edit any concurrency.

6
  • +1; Works great! I'd add HKEY_CLASSES_ROOT\Directory\shell\runas:Extended="" etc. so that this appears on the shift+right-click menu rather than the right-click menu. Also, you have - for keys. Doesn't that delete the keys and sub-values? Shouldn't you leave the existing keys there, or is it probably safe/won't conflict? Mar 13, 2012 at 1:01
  • 2
    @MerlynMorgan-Graham I believe the places that I used the minus are places that typically don't have keys. This is simply protection against anything else being there. In theory, you could have a RunAs PrintServer or something, but I'd assume if someone is doing that, they should know what they're doing. I work in IT and have seen people try this kind of thing and any attempt to insert better code typically clashes with previous code. Feel free to remove the minus signs. Mar 13, 2012 at 4:43
  • The fact that you've given it thought gives me enough comfort to use the code you've provided :) Mar 13, 2012 at 4:49
  • 1
    Note that it's only the runas verb that gives this the ability to elevate. The HasLUAShield only shows the shield.
    – Deanna
    May 7, 2015 at 8:14
  • Is it possible to modify it also for files? (right click will open a cmd on location where that file is found)
    – Royi Namir
    Dec 25, 2017 at 19:05
4

The easiest way I know of is to simply install CmdOpen. I know you're trying to avoid installing something, but this is a 46 KB install, and the shell extensions themselves are less than 20 KB each (1 for 32-bit, 1 for 64-bit). It's also got some other useful features that you're not going to get out of the box.

It's certainly easier than struggling with registry edits -- especially if you're having problems.

1

I solved it adding this registry keys:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\openCmdHereAsAdmin]
@="Open command prompt here as admin"

[HKEY_CLASSES_ROOT\Directory\Background\shell\openCmdHereAsAdmin\command]
@="C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -Command \"Start-Process cmd -ArgumentList '/s,/k,pushd,%V' -Verb RunAs\""

Save it on a .reg file and double click on the file to install it on your registry.

0

If you don't want to install powertoys, try Ultimate Windows Tweaker. It's a one-run .exe that you can delete after.

0

How are you trying to import the .reg file?

The error message suggests you are using the IMPORT option in RegEdit

Try double clicking it in Windows Explorer.

1
  • That's what I was trying Jul 10, 2010 at 13:58
-1

Just the see below link

Add Command prompt here to right click of mouse or in the context menu Every thing is described there.

2
  • -1 I don't seen any evidence that this will elevate by default under Windows 7, as the OP asked. It will add a link that already exists under Windows 7, but won't add elevation. Can you provide details to the contrary? Mar 13, 2012 at 0:50
  • @MerlynMorgan-Graham is correct, this opens a regular command-prompt, not an elevated one. You need to add the HasLUAShield value to make it have admin privileges.
    – Synetech
    Nov 6, 2012 at 1:43
-2

Just right click while holding Shift. The option will appear in the context menu.

-3

You don't need to add anything to Windows 7, the elevated command prompt is already included, just hold the shift key down when you right click in a folder, the context menu provides additional options, including the Admin command prompt.

If that doesn't work for you, the two reg files you linked to above do work. Make sure you only use Notepad to create the reg file as some text editors add formatting, which will cause problems.

Open a new Notepad text file copy and past the link from the first script then save the file as elecmd.reg Make sure the file file has not been saved with an additionl .txt extension. To check that, In Explorer, open the Tools menu/Folder Options/View/ Untick the box for 'Hide extensions of Known file types. Once confirmed, right click on the elecmd.reg file and select merge.

I've just been through that process and it does work.

2
  • 4
    No. No it doesn't. Jun 12, 2010 at 0:15
  • 1
    +1 for Shift->Right clicking a folder! Hadn't seen that before. Thanks!
    – BQ.
    Aug 10, 2010 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .