Skip to content

Instantly share code, notes, and snippets.

@Prince-Mandor
Created November 14, 2016 13:49
Show Gist options
  • Save Prince-Mandor/c1db742bd2951989db84acfbc7b9562f to your computer and use it in GitHub Desktop.
Save Prince-Mandor/c1db742bd2951989db84acfbc7b9562f to your computer and use it in GitHub Desktop.
add elevated command prompt to shift-right click menu in windows
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\*\shell\runas]
[HKEY_CLASSES_ROOT\*\shell\runas]
@="Command prompt here (as Admin)"
"Extended"=""
"HasLUAShield"=""
[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /s /k for %%X in (\"%V\") do @pushd %%~dpX"
[-HKEY_CLASSES_ROOT\Directory\shell\runas]
[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Command prompt here (as Admin)"
"Extended"=""
"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]
@="Command prompt here (as Admin)"
"Extended"=""
"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]
@="Command prompt here (as Admin)"
"Extended"=""
"HasLUAShield"=""
[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""
[-HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas]
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas]
"Extended"=""
"HasLUAShield"=""
@="Command prompt here (as Admin)"
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""
@Prince-Mandor
Copy link
Author

Just to remember what's this %V means:

%* – Replace with all parameters.
%~ – Replace with all parameters starting with and following the second parameter.
%0 or %1 – The first file parameter. For example "C:\Users\Eric\Desktop\New Text Document.txt". 
            Generally this should be in quotes and the applications command line parsing should
            accept quotes to disambiguate files with spaces in the name and different command line
            parameters (this is a security best practice and I believe mentioned in MSDN).
%<n> (where <n> is 2-9) – Replace with the nth parameter.
%s – Show command.
%h – Hotkey value.
%i – IDList stored in a shared memory handle is passed here.
%l – Long file name form of the first parameter. Note that Win32/64 applications will be passed the
      long file name, whereas Win16 applications get the short file name. Specifying %l is preferred as
      it avoids the need to probe for the application type.
%d – Desktop absolute parsing name of the first parameter (for items that don't have file system paths).
%v – For verbs that are none implies all. If there is no parameter passed this is the working directory.
%w – The working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment