Question

When I open cmd on my laptop it is defaulting to the F: drive. This is troubling me does anyone know how it got that way or how to get it back to where it opens to the C: drive by default?

Was it helpful?

Solution

I believe it defaults to %HOMEDRIVE%\%HOMEPATH% so if you can muck about with those environment variables that might be an option. I can't edit these environment variables on my company's network, so I had to use the AutoRun to change it to something sane.

OTHER TIPS

Use the command

C:

To change to the drive C. It would of course work for any drive letter.

Very minor nit: if you're using Windows 7 you don't need the cmdhere powertoy, it's built in to Explorer.

You just navigate to a directory in Windows Explorer then hold down the shift key and right click. "Open command window here" is one of the selections on the context menu.

When it comes to opening cmd.exe in a specific directory, I just create a shortcut to cmd.exe and then in the shortcut properties I set "Start in:" to the drive/directory I want it to start in.

Using a shortcut allows me to customize the cmd.exe windows depending on what I'm using it for. For normal file editing/viewing I use a 180x60 window and appropriate font, but when I want to read/search log files I have a shortcut that opens a 260x100 window with a smaller font. That way I can view most long log file lines without having to use the horizontal scroll.

http://blog.stevienova.com/2007/04/08/change-your-default-cmd-prompt-path/

Sometimes, your path when you go to start->run, CMD will be something you don’t want. In active directory or on an NT domain, sometimes your default home path might be a network drive. This isn’t so good when you are offline or drop offline after being online. The CMD prompt is set to a place where you can’t get to.

To change the path, you can edit the registry (at your own risk)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor] “Autorun”=”c:”

This will change the path to your c: drive.

quick answer: cmd /k c:

long answer to make it "automagical": http://windowsxp.mvps.org/autoruncmd.htm

In RegEdit.exe I created a String:

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

The value I used for AutoRun was "D:"

If you are opening it from a shortcut change the working dir for the shortcut.

In addition to the other answers, there's a nice powertoy for XP called "open command window here." It adds an option to your right-click context menu when you click inside a folder to open a command window using that directory as the starting path.

http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx

I ran into a similar issue where cmd would always open up in a particular directory (annoying when running scripts which invoke cmd). The best way to deal with this is to edit your autorun settings. Raymond Chen has a nice article about this here: http://blogs.msdn.com/oldnewthing/archive/2007/11/21/6447771.aspx

The summary is that when you start a command shell, it checks the autorun registry key, and executes the commands stored there. The registry keys it checks are:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
    and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top