Location:
State:
Carrier
Country
Status

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:WINDOWSsystem32which 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:Usersmyaccountnameyet when I launch the Command Prompt it still goes to C:WINDOWSsystem32.



Any ideas how to make this work?

Create a shortcut with:
C:Windowssystem32cmd.exe /K cd %USERPROFILE%
and set to run as Admin
ORuse 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 herewill 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_ROOTDirectoryBackgroundshell unas]
@="Admin Command Here"
"NoWorkingDirectory"=""
"HasLUAShield"=""
"Position"="Top"

[HKEY_CLASSES_ROOTDirectoryBackgroundshell unascommand]
@="cmd.exe /s /k pushd "%V""


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

[HKEY_CLASSES_ROOTDirectoryBackgroundshell unascommand]
@="cmd.exe /s /k pushd "%V""

I changed it to

[HKEY_CLASSES_ROOTDirectoryBackgroundshell unascommand]
@="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.

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:UsersRich

I edited for the user above:
Create a shortcut with:
C:Windowssystem32cmd.exe /K cd %USERPROFILE%
and set to run as Admin
  • cmd.zip (804 Bytes, 10 views)

Would this work for you?

Open Command Window Here as Administrator - Windows 7 Help blog

Right click context menu is more flexible. If your file explorer is currently pointing at your USER then it will open as C:UsersRich

I edited for the user above:
Create a shortcut with:
C:Windowssystem32cmd.exe /K cd %USERPROFILE%
and set to run as Admin
Perfect!!! Thanks (also thanks on eightblog )

Would this work for you?

Open Command Window Here as Administrator - Windows 7 Help blog
I had one similar but it was not an Admin Command Prompt.. I like this one better.

Thanks Shawn.

You're welcome Rich. Glad it could help.

Get elevated command prompt to open in my user directory