Saturday, February 21, 2009

How To Change the default CMD directory

Change the path you are in when you run the CMD command

1)    Regedit
2)    HKEY_CURRENT_USER\Software\Microsoft\Command Processor
3)    In the right-pane, double-click Autorun and set the startup folder path as its data, preceded by “CD /d “. If Autorun value is missing, you need to create one, of type REG_EXPAND_SZ or REG_SZ in the above location.
a.    Example:  To set the startup directory to F:\Windows, set the Autorun value data to CD /d F:\Windows
b.    You may also use a batch file so that it executes the contents automatically upon launching the Command Prompt. To view the entire list of arguments supported by CMD.EXE and their description, type CMD /? at the Command Prompt.

4)    You can also set the default Prompt in the Autorun key. To execute more than one command automatically at Command Prompt startup, type the commands in a Notepad document and save as a .BAT file. Then, type the full path to the batch file in the Autorun field in the registry. Sample Batch file:
@CD /D F:\Utilities
@Prompt$P$G

Minor side-effect - “Autorun” value and CmdHere Powertoy
Open Command Window Here PowerToy adds an Open Command Window Here context menu option on file system folders, giving you a quick way to open a command window (cmd.exe) pointing at the selected folder. The Open Command Window Here functionality is affected if you set the Command Processor Autorun value as described earlier in this article.
To re-enable the functionality of Open Command Window Here PowerToy, and have the Command Processor Autorun feature enabled at the same time, use these steps:
•    Click Start, Run and type regedit.exe
•    Navigate to the following location:
HKEY_CLASSES_ROOT \ Directory \ shell \ cmd \ command
•    In the right-pane, double-click (default) and change the following data:
cmd.exe /k “cd %L”
to
cmd.exe /d /k “cd %L”
•    Exit the Registry Editor
Note: If /D parameter IS specified on the command line, then when CMD.EXE starts, it ignores the AutoRun registry variables in the following locations.
HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Command Processor \ AutoRun
HKEY_CURRENT_USER \ Software \ Microsoft \ Command Processor \ AutoRun

No comments:

Post a Comment