I use the following registry tweak to create context menu options that open CMD and PowerShell with elevated priveleges, but selecting either option starts CMD/PowerShell, then restarts it, which creates a delay that I wish not be there: Code: [HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHereAsAdmin] @="Elevated Command Prompt" "Extended"=- "Icon"="imageres.dll,-5324" [HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHereAsAdmin\command] @="cmd /c echo|set/p=\"%L\"|powershell -NoP -W 1 -NonI -NoL \"SaPs 'cmd' -Args '/c \"\"\"cd /d',$([char]34+$Input+[char]34),'^&^& start /b cmd.exe\"\"\"' -Verb RunAs\"" [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAsAdmin] @="Elevated Command Prompt" "Extended"=- "Icon"="imageres.dll,-5324" [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAsAdmin\command] @="cmd /c echo|set/p=\"%V\"|powershell -NoP -W 1 -NonI -NoL \"SaPs 'cmd' -Args '/c \"\"\"cd /d',$([char]34+$Input+[char]34),'^&^& start /b cmd.exe\"\"\"' -Verb RunAs\"" [HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHereAsAdmin] @="Elevated Command Prompt" "Extended"=- "Icon"="imageres.dll,-5324" [HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHereAsAdmin\command] @="cmd /c echo|set/p=\"%L\"|powershell -NoP -W 1 -NonI -NoL \"SaPs 'cmd' -Args '/c \"\"\"cd /d',$([char]34+$Input+[char]34),'^&^& start /b cmd.exe\"\"\"' -Verb RunAs\"" [-HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHereAsAdmin] ; To allow mapped drives to be available in command prompt [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System] "EnableLinkedConnections"=dword:00000001 I used to use a different registry tweak that provided the same conext menu options, but didn't create any delays, just opened CMD with elevated priveleges instantly.
Obviously your code goes through cmd, powershell, then starts yet another cmd process. Using parameters to set it to run on background won't ever work across standard/elevated barrier, just like passing parameters does not. There's only one built-in way to do what you want, and it requires the dedicated verb "runas" and the "HasLUAShield" configuration, like this: Code: Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAsAdmin] [-HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHereAsAdmin] [-HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHereAsAdmin] [-HKEY_CLASSES_ROOT\Folder\shell\OpenCmdHereAsAdmin] [HKEY_CLASSES_ROOT\Directory\background\shell\runas] "MuiVerb"="Elevated Command Prompt" "Icon"="imageres.dll,-5324" "Position"="Middle" "NoWorkingDirectory"="" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Directory\background\shell\runas\command] @="C:\\Windows\\System32\\cmd.exe /k pushd \"%W\"" [HKEY_CLASSES_ROOT\Drive\shell\runas] "MuiVerb"="Elevated Command Prompt" "Icon"="imageres.dll,-5324" "Position"="Middle" "NoWorkingDirectory"="" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Drive\shell\runas\command] @="C:\\Windows\\System32\\cmd.exe /k pushd \"%L\"" ;[-HKEY_CLASSES_ROOT\Directory\background\shell\runas] ;[-HKEY_CLASSES_ROOT\Drive\shell\runas]
Thanks! It isn't my script, but the one from TenForums. I can't post full link due MDL newbie user limitation, but the link ends in "59686-open-command-window-here-administrator-add-windows-10-a.html" . I don't know nearly enough to interpret what you're saying... I guess you're saying the script in my OP isn't fully functional? Again, I have no idea... Could you please provide a similar script, but for PowerShell? The one I'm using is from (TenForums) 60177-add-open-powershell-window-here-administrator-windows-10-a.html .
If you want to have both CMD and Powershell and without delay, it's not possible as I've explained - there's only one runas entry. No point in having both either, since it's just so trivial to write powershell in cmd and cmd in powershell, respectively. So, the powershell alternative: Code: Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\background\shell\runas] "MuiVerb"="Elevated PowerShell" "Icon"="powershell.exe,0" "Position"="Middle" "NoWorkingDirectory"="" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Directory\background\shell\runas\command] @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -nop -noe -c $A=([environment]::commandline-split'-[-]%%+ ?',2)[1]; set-location -lit $A; # --%% %W" ; special-characters-friendly argument parsing by AveYo [HKEY_CLASSES_ROOT\Drive\shell\runas] "MuiVerb"="Elevated PowerShell" "Icon"="powershell.exe,0" "Position"="Middle" "NoWorkingDirectory"="" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Drive\shell\runas\command] @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -nop -noe -c set-location -lit '%L'" ; special-characters-friendly argument parsing by AveYo ;[-HKEY_CLASSES_ROOT\Directory\background\shell\runas] ;[-HKEY_CLASSES_ROOT\Drive\shell\runas]
You lost me there... The script in the OP has a delay whenever I try to start CMD, but the one you provide does not, yet both allow me to start CMD as Admin (Elevated Priveleges) via right-click context menu. Is that because the CMD context menu script involves launching PowerShell? Why does it do it in the first place if it isn't necessary and doesn't add PowerShell context menu? Anyway, your scripts make me happy - that's the most important part . THANK YOU! EDIT: Hmm.. Your PowerShell script simply replaces CMD context menu option with PowerShell option, but doesn't add it to the existing CMD context menu option. Is that because CMD is basically the same thing as PowerShell? AFAIK, PowerShell can perform some exclusive commands like CMD can't, such as removal of UWP Apps, but maybe not...
Maybe you've missed it, here it is in bold. I would just use the PowerShell one, and whenever needing cmd, just enter cmd in powershell.. Else, you're gonna have to pick one of the two to be used with the delay you've complained in OP
"Just" use --[Insert 3rd party binary]-- vs. make a 5-line plain-text reg file and double-click it. Are you serious? Why not --[Build your own shell extension]-- then. Or --[Use Arch]--
@BAU Aside that other options were already given, so no need to reinvent the wheel on that side, I took the chance to suggest something really really worth using. Something that simplifies the task of launching a cmd shell w/o the need to launch stupid PS things before. Sometimes the "I like to learn" part is just overruled by the "just works" part.
you can try this. it work without delay. its auto elevate to Admin privileges because EnableLUA is disabled. work from inside Folder -> left click & selected folder -> left click https://forums.mydigitallife.net/th...fications-overview.83744/page-36#post-1695374 https://forums.mydigitallife.net/th...fications-overview.83744/page-42#post-1699540
edit because we posted at the same time it might be great, worth using. was not single-ing you out. op had a working reg solution. it just did not like how it worked. at no point did he request a c++ or said anything-goes just NO. never-ever provide a "solution" that gets rid of a mild-annoyance by completely removing a security feature. it's enough microsoft does not care enough about UAC. but to disable it completely is kinda irresponsible. op wants cmd / ps to run as admin. it is implied it does not want everything on it's pc to run as admin as well, else would have asked for that..