New
#40
huh...don't know what you changed in that test version, but it worked
huh...don't know what you changed in that test version, but it worked
@Brink Use these values instead. Tested on directories with dollar signs, spaces, ampersands, and apostrophes.
Code:[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\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\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\LibraryFolder\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\""
It's not as confusing as it looks. It's simply passing the %V or $L path into powershell, tying it to $Input so no syntax errors occur. By using echo|set/p= it's shaving off the newline as well as keeping it surrounded in quotes to handle as many different characters as possible.
Finally, $Input is surrounded by quotes using "[char]34" like so: $([char]34+$Input+[char]34). (It would be nice if I could just pass it pre-quoted, but then folders with ampersands become a problem.)
-W 1 -NonI -NoL (i.e. -WindowStyle Hidden -NonInteractive -NoLogo) aren't really necessary, but in theory, they might shave off some milliseconds off how long the 'launch window' is visible for. I think they do, but that might be placebo? I included them just in case.
This was all quite a bitch to figure out.
thank you very much, I used your files (and the powershell one) to teach myself how to this.
I can confirm that its now faster
Hey all,
I have utilized these forums for a couple of years now and figured I'd finally join in.
How can I make this work when trying to open cmd prompt with admin on a persistent mapped drive?
When I try to do the shift+right click - open cmd prompt here (Admin) as well if I click directly on the drive itself and try and open the cmd prompt as admin - it flashes a window and immediately closes - never opening the cmd prompt with admin.
Any help / direction much appreciated.
Thanks!