Open command window here as administrator - Add in Windows 10  

Page 11 of 13 FirstFirst ... 910111213 LastLast

  1. Posts : 68,836
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #100

    Oldhead said:
    Upgraded today from build 2004 to 20H2 ver 19042-870 and the previously inserted (open admin command window here ) in my context menu within desktop has disappeared ???? but still have right click (open command line here as admin ) within file background ???
    Has the new build overwritten previous added shortcuts .?? to desktop context menu

    When upgading to new build do i need to reinsert the shortcut shown at Brinks first post .
    It's not uncommon for an update to restore default settings.

    You can add the context menu back using the tutorial in the first post though.
      My Computers


  2. Posts : 1,203
    11 Home
       #101

    Open command window here as administrator - Add in Windows 10
    If you, like me, prefer to 'Shift+Open here' the command window as an administrator without getting greeted by the UAC prompt, then this might be for you. I also got annoyed by the little stroboscopic side effect resulting from how cmd /c start is used in various tutorials so, I went ahead and decided to apply old medicine─nothing too complicated.
    I included a README.txt file in the zip and added some additional brief comments in each file about how to set this all up right. At first I was going to write up a full-blown tutorial, but then I got lazy and bored so, please feel free to reply with your suggestions like possible improvements, questions, or other related remarks.
    Attachment 320066
    Changelog:

    • The .reg file wasn't working properly so it has now been corrected.
    • It now also includes the option to add Shift+Open command window here as standard user.
    • It now also includes the .reg files needed to remove these added keys from Windows registry.
      My Computers


  3. Posts : 24
    Windows 11 Pro 64-bit 22H2 22621.1
       #102

    New cleaner method to run CMD as admin here


    Hi all,

    I just wanted to share an alternative to the current solution (Open Command Prompt Here). This solution will also handle apostrophes or special characters in the target directory. Here's the registry entry:

    Code:
    powershell.exe -WindowStyle Hidden -NoProfile -Command "Start-Process -Verb RunAs cmd.exe -ArgumentList \"/k pushd \"\"%V/\"\"\"
    I think it's much cleaner and less obfuscated compared to the current command:

    Code:
    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"
    All credit goes to mklement0 from this StackOverflow question.
      My Computer


  4. Posts : 1,203
    11 Home
       #103

    elecmd3.zip
    V3:
    • On Windows 11, the command window now correctly reports Windows 11 instead of Windows 10.
    • Added UTF-8 support to handle foldernames that contain an apostrophe and/or special characters correctly.

    V2:
    • The .reg file wasn't working properly so it has now been corrected.
    • It now also includes the option to add Shift+Open command window here as standard user.
    • It now also includes the .reg files needed to remove these added keys from Windows registry.
      My Computers


  5. Posts : 24
    Windows 11 Pro 64-bit 22H2 22621.1
       #104

    hdmi said:
    @hdmi

    Just wanted to give you a heads-up. The Non-UAC version of your script (The one that you need to create a task for) fails when the target directory has a ^ (Caret) or & (Ampersand) anywhere in the path. These need to be escaped somehow. I'm going to give it a shot in a little bit to see if I can get it working.

    Also, do you by any chance have a method or command for opening PowerShell 5 as admin?

    BTW, I forgot to say it before, but I really appreciate your contributions. The current version of the reg file for this thread is bulletproof and works flawlessly on any directory.

    Also, if people want to suppress the window flashing but don't care about the UAC prompt, there is a small tool called RunHiddenConsole that will suppress the window flashing.

    Code:
    "C:\Tools\scripts\BIN\RunHiddenConsole.exe" 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"
    The above registry command will completely hide the window flashing. Just make sure RunHiddenConsole is available in the path specified in the command.
      My Computer


  6. Posts : 7,606
    Windows 10 Home 20H2
       #105

    cultmethod said:
    the target directory has a ^ (Caret) or & (Ampersand) anywhere in the path. These need to be escaped somehow.
    How would you escape D:\$Foldername\?
      My Computer


  7. Posts : 1,203
    11 Home
       #106

    cultmethod said:
    @hdmi

    Just wanted to give you a heads-up. The Non-UAC version of your script (The one that you need to create a task for) fails when the target directory has a ^ (Caret) or & (Ampersand) anywhere in the path. These need to be escaped somehow. I'm going to give it a shot in a little bit to see if I can get it working.

    Also, do you by any chance have a method or command for opening PowerShell 5 as admin?

    BTW, I forgot to say it before, but I really appreciate your contributions. The current version of the reg file for this thread is bulletproof and works flawlessly on any directory.

    Also, if people want to suppress the window flashing but don't care about the UAC prompt, there is a small tool called RunHiddenConsole that will suppress the window flashing.

    Code:
    "C:\Tools\scripts\BIN\RunHiddenConsole.exe" 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"
    The above registry command will completely hide the window flashing. Just make sure RunHiddenConsole is available in the path specified in the command.
    Update:

    elecmd4.zip

    - - - Updated - - -

    cultmethod said:
    Also, do you by any chance have a method or command for opening PowerShell 5 as admin?
    I do now.
    Add Open PowerShell window here as administrator in Windows 10
      My Computers


  8. Posts : 1
    Windows 10 EE LTSC 21H2
       #107

    Hi :)

    I recently returned to Windows from macOS and was missing something like this, so here I am.

    It works as advertised, but I noticed immediately that the command prompt that opens doesn't open with the style that I've configured for the "normal" system command prompt. That is to say, if I open Command Prompt as Administrator via Win+X or by searching in the Start Menu and opening as Administrator from there, I get my customized command prompt window. It has a semi-translucent red tinted (to warn me that it's running as admin) background, a certain size and scrollback buffer, font, etc.

    If I run via this context menu thing, however, it defaults back to the vanilla black background, unconfigured Windowsy command prompt window.

    I don't know how Windows stores these profiles - for the non-admin prompts I've configured a bluish tinted background, and it stores these profiles separately and loads them automatically. I did notice, however that when I open the command prompt using this method posted here, the title of the window reads,
    Code:
    Administrator: C:\Windows\System32\cmd.exe
    whereas on my custom configured command prompt windows opened "normally," it reads,
    Code:
    Administrator: Command Prompt
    Does anyone know why this is behaving like it is, if it's related to the title at all, and if there's a way to get these prompts launched from this context menu thing to load the saved profile?

    Thanks :)
      My Computer


  9. Posts : 1,203
    11 Home
       #108

    ManOfManyWords said:
    Hi :)

    I recently returned to Windows from macOS and was missing something like this, so here I am.

    It works as advertised, but I noticed immediately that the command prompt that opens doesn't open with the style that I've configured for the "normal" system command prompt. That is to say, if I open Command Prompt as Administrator via Win+X or by searching in the Start Menu and opening as Administrator from there, I get my customized command prompt window. It has a semi-translucent red tinted (to warn me that it's running as admin) background, a certain size and scrollback buffer, font, etc.

    If I run via this context menu thing, however, it defaults back to the vanilla black background, unconfigured Windowsy command prompt window.

    I don't know how Windows stores these profiles - for the non-admin prompts I've configured a bluish tinted background, and it stores these profiles separately and loads them automatically. I did notice, however that when I open the command prompt using this method posted here, the title of the window reads,
    Code:
    Administrator: C:\Windows\System32\cmd.exe
    whereas on my custom configured command prompt windows opened "normally," it reads,
    Code:
    Administrator: Command Prompt
    Does anyone know why this is behaving like it is, if it's related to the title at all, and if there's a way to get these prompts launched from this context menu thing to load the saved profile?
    Update:

    elecmd5.zip
    Thanks :)
    You're welcome!
      My Computers


  10. Posts : 11
    win10
       #109

    Is it possible to run a program directly with cmd from the context menu? I have tried to add
    [HKEY_CLASSES_ROOT\*\shell\OpenCmdHereAsAdmin\command] to the script, and tried to add the "%1" variable. But unfortunately it doesnt work
      My Computer


 

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 02:05.
Find Us




Windows 10 Forums