Get elevated command prompt to open in my user directory


  1. Posts : 14,046
    Windows 11 Pro X64 22H2 22621.1848
       #1

    Get elevated command prompt to open in my user directory


    I changed Command Prompt on my Taskbar so when I click on it, it opens as Administrator.
    That sets the default directory as C:\WINDOWS\system32 which I don't like, since any files I create that do not have a path specified will be created there.

    I want it to open in my user directory.

    When I look at the properties I see Start in: %homedrive%%homepath% which converts to C:\Users\myaccountname yet when I launch the Command Prompt it still goes to C:\WINDOWS\system32.

    Get elevated command prompt to open in my user directory-cmdpro1.jpg

    Any ideas how to make this work?
      My Computers


  2. Posts : 2,799
    Linux Mint 20.1 Win10Prox64
       #2

    Create a shortcut with:
    C:\Windows\system32\cmd.exe /K cd %USERPROFILE%
    and set to run as Admin
    OR use the below for any folder


    Copy and paste the following in a .reg file then merge to the registry. This will add to right click context menu
    Right click ->Open Admin Command here will open the command default to the current folder where the mouse is pointing at. This is more flexible than just your user folder.

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
    @="Admin Command Here"
    "NoWorkingDirectory"=""
    "HasLUAShield"=""
    "Position"="Top"

    [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
    @="cmd.exe /s /k pushd "%V""

    Get elevated command prompt to open in my user directory-.jpg
    Last edited by topgundcp; 25 Sep 2015 at 19:19. Reason: Typo. added "" to the end
      My Computer


  3. Posts : 14,046
    Windows 11 Pro X64 22H2 22621.1848
    Thread Starter
       #3

    The last part seems to be wrong, extra double quote at end.

    [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
    @="cmd.exe /s /k pushd "%V""

    I changed it to

    [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
    @="cmd.exe /s /k pushd "%V"

    and it works, but opens to my Desktop directory. I'd like to backup one level to my user directory but this is useable, thanks.

    I would still like to be able to modify the Command Prompt.
      My Computers


  4. Posts : 2,799
    Linux Mint 20.1 Win10Prox64
       #4

    and it works, but opens to my Desktop directory. I'd like to backup one level to my user directory but this is useable, thanks.

    I would still like to be able to modify the Command Prompt.
    Right click context menu is more flexible. If your file explorer is currently pointing at your USER then it will open as C:\Users\Rich

    I edited for the user above:
    Create a shortcut with:
    C:\Windows\system32\cmd.exe /K cd %USERPROFILE%
    and set to run as Admin
    Get elevated command prompt to open in my user directory Attached Files
    Last edited by topgundcp; 25 Sep 2015 at 19:43.
      My Computer


  5. Posts : 68,836
    64-bit Windows 11 Pro for Workstations
       #5
      My Computers


  6. Posts : 14,046
    Windows 11 Pro X64 22H2 22621.1848
    Thread Starter
       #6

    topgundcp said:
    Right click context menu is more flexible. If your file explorer is currently pointing at your USER then it will open as C:\Users\Rich

    I edited for the user above:
    Create a shortcut with:
    C:\Windows\system32\cmd.exe /K cd %USERPROFILE%
    and set to run as Admin
    Perfect!!! Thanks (also thanks on eightforums :) )
      My Computers


  7. Posts : 14,046
    Windows 11 Pro X64 22H2 22621.1848
    Thread Starter
       #7

    I had one similar but it was not an Admin Command Prompt.. I like this one better.

    Thanks Shawn.
      My Computers


  8. Posts : 68,836
    64-bit Windows 11 Pro for Workstations
       #8

    You're welcome Rich. Glad it could help. :)
      My Computers


 

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




Windows 10 Forums