So, I know you can create a shortcut to an administrator-level command prompt (as described in this question), but what I'm seeing is that whenever I use such a shortcut, it always drops me into c:\windows\system32\ path.

I've tried specifying that shortcut's properties to set the "start in" path I need, but to no avail. It seems any time I run cmd.exe "As Administrator," it completely disregards the shortcut's paths and sticks to c:\windows\system32\

Any suggestions on how to get Windows 7 to respect the shortcut's "start in" path?

link|improve this question

75% accept rate
feedback

4 Answers

up vote 1 down vote accepted

I found a way around this. In the shortcut, change the command line to:

C:\Windows\System32\cmd.exe /k "cd c:\"

In this case it changes the starting directory to the root of C:. You can set your own parameters.

link|improve this answer
Excellent, Peter. Thanks! – Alex Beynenson Jun 24 '10 at 11:10
feedback

Launch an elevated Command Prompt from the context menu

To add the Open Command Window Here (Administrator) option to the context menu for file system folders, use the following REG file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Open Command Window Here (Administrator)"

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

To add the entry to Computer (My Computer) context menu, use the following REG file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\runas]
@="Open Command Prompt (Administrator)"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\runas\command]
@="cmd.exe"

Usage

Copy the above contents to Notepad, and save the file with .REG extension. Then right-click the REG file and choose Merge.

Source

link|improve this answer
This is a good suggestion, but not quite what I'm looking for. I'm looking for a way to create an arbitrary shortcut, which I can pin to the taskbar. – Alex Beynenson Dec 28 '09 at 2:39
i'm not sure if this is possible, unless you change the start directory for CMD globally: To change default path where cmd starts add/edit REG_SZ Autorun in HKEY_CURRENT_USER\Software\Microsoft\Command Processor replacing the Value Data with a folder or directory preceded by a CD\ – Molly7244 Dec 28 '09 at 3:12
Thanks for this suggestion. It's a decent workaround. – Alex Beynenson Dec 28 '09 at 13:22
feedback

You can right click CMD, select Properties and in the "Start in" box clear whatever is there, entering: %SystemRoot%\system32. Click OK.

link|improve this answer
feedback

It will happen if the place where you want to open your command prompt is on a different drive than the shortcut is. The solution is to put an additional command in the shortcut:

C:\Windows\System32\cmd.exe /k "a: & cd a:\something"

In this case it will change to the drive a: from the current drive, and than open the a:\something folder. The & operator is used to put multiple commands in a single line at the windows command prompt.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.