Open command window here as administrator - Add in Windows 10  

Page 5 of 11 FirstFirst ... 34567 ... LastLast

  1. Posts : 280
    Windows 10 Pro 64-Bit
       #40

    huh...don't know what you changed in that test version, but it worked
      My Computer

  2. Brink's Avatar
    Posts : 56,311
    64-bit Windows 10 Pro for Workstations build 21359
    Thread Starter
       #41

    BrokenDaily said:
    huh...don't know what you changed in that test version, but it worked

    I changed the variable to use V instead of L.

    Great news. I'll update the .reg files in the tutorial now.
    Last edited by Brink; 11 Oct 2019 at 09:44. Reason: typo
      My Computers


  3. Posts : 10
    Windows 10
       #42

    @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.
      My Computer

  4. Brink's Avatar
    Posts : 56,311
    64-bit Windows 10 Pro for Workstations build 21359
    Thread Starter
       #43

    Thank you @jungf. Tutorial now updated to use these commands instead.
      My Computers

  5. Ben K AU's Avatar
    Posts : 4
    Win10 1909
       #44

    thank you very much, I used your files (and the powershell one) to teach myself how to this.
      My Computer

  6. Brink's Avatar
    Posts : 56,311
    64-bit Windows 10 Pro for Workstations build 21359
    Thread Starter
       #45

    Ben K AU said:
    thank you very much, I used your files (and the powershell one) to teach myself how to this.
      My Computers


  7. Posts : 934
    Windows 10 Pro
       #46

    I can confirm that its now faster
      My Computer

  8.   My Computer


  9. Posts : 3
    Windows 10
       #48

    Open command window as admin on mapped drive


    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!
      My Computer

  10. Brink's Avatar
    Posts : 56,311
    64-bit Windows 10 Pro for Workstations build 21359
    Thread Starter
       #49

    AnalyzeThis said:
    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!
    Hello AnalyzeThis, and welcome to Ten Forums.

    I haven't worked out how to get it to work properly for a mapped network location yet.
      My Computers


 
Page 5 of 11 FirstFirst ... 34567 ... LastLast

Tutorial Categories

Open command window here as administrator - Add in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 03:58.
Find Us




Windows 10 Forums