Tara Kizer Blog

Tara Kizer

Open Command Window Here

Most of you probably already have done this, but just in case you haven't and find yourself frequently using cmd to run commands such as sqlcmd, you will find this registry "hack" useful. 

I use sqlcmd on a weekly, if not daily, basis.  I'm constantly switching directories to where my scripts are.  Rather than switching directories in cmd, I can instead use the "Open Command Window Here" option in Windows Explorer.  To get this option on your machine, save the below as a reg file and then double-click on it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd]
@="Open Command Window Here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd\command]
@="cmd.exe /k \"cd %L\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\cmd]
@="Open Command Window Here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\cmd\command]
@="cmd.exe /k \"cd %L\""

After you've modified the registry, open up Windows Explorer, right click on a directory, and then select the new option.  Notice how a cmd window opens in the requested directory.

Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system.  Use the information provided at your own risk.

Legacy Comments


Ron
2008-06-26
re: Open Command Window Here
For the lazy, if you're using windows xp, there's a powertoys installer that will do this for you.

http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx