# Sunday, 19 February 2012

Do you know how to get a command prompt and have its "current directory" be a specific directory in which you want to do some work? Sure you do. In fact, I bet you know at least three ways.

First, the how-hard-can-I-make-this way: Click Start, and mouse around until you see Command Prompt. Click that. Change drives if need be (by typing D: or E: or whatever) and then change directories with the CD command a lot.

Did you know that pressing Tab will autocomplete file and folder names? It even puts the quotes in there for you, since spaces are interpreted as "this is the end of the file and here are some other parameters". But as I said, that's the slow way.

A lot of times, I have a Windows Explorer open to the very folder where I would like the command prompt. I've looked at the files and I know I want to install a service or register a DLL or run an exe or something. Here are some ways to get to that command prompt more quickly in those cases.

First, get yourself a command prompt, and get on the right drive (eg D:). Then, type "cd " in the command prompt, and click on the Windows Explorer address bar so it becomes plain text. Copy the text with Ctrl+C, and then in the command prompt, bring up the system menu, choose Edit, and then Paste:

This is really the long way though. First, you can do a cool drag and drop trick. In the command prompt, get on the right drive and type "cd " , but then in the Windows Explorer click the folder image next to the path, and drag that into the command prompt window:

Not bad, but try this. Close that command prompt, and shift-right-click in the background of the Windows Explorer folder:

That's quicker, right? Sure it is. But two issues - first, a shift right click followed by mousing down and clicking does take a little dexterity. And second, what if I wanted a certain kind of command prompt - say a Visual Studio Command Prompt? Well, that's where we take a turn into stuff I didn't know until just a few days ago.

Go back to that Windows Explorer, click as though you were going to overtype the address in the address bar (you did know you could do that, right?) and type cmd, then press enter:

It even changes drives (to D:) if you need to. Wow! Now, what else can you type there? Well, I've tried notepad foo.txt, for example, and it creates a file in that folder for me and opens in it notepad. Do you know how many times I've done right-click, New, Text File, type the new name, enter to accept that, enter to edit it? This is way quicker. (It doesn't seem to worker for newfangled apps like WinWord, unfortunately.) Or, how about this:

You need the pairs of double quotes at beginning and end - you might have this string in a handy text file on your desktop, or you might move that batch file to somewhere with a shorter path. Because that particular string gives you a "Visual Studio Command Prompt" in the folder - perfect for installing services and whatnot.

Just goes to show you, there's always something new to learn. I use the cmd trick almost every day. And my thanks to whoever coded that, whether it was 20 years ago or more recently.

Kate

Sunday, 19 February 2012 10:21:25 (Eastern Standard Time, UTC-05:00)  #    Comments [1]
Sunday, 19 February 2012 13:17:43 (Eastern Standard Time, UTC-05:00)
Neat!

That being said, I just use (and strongly recommend) my trusty Total Commander for these (and plenty other) kinds of tasks, it's very convenient to issue commands and work w/ the command line and has great keyboard shortcuts. Take a look at ENTER, SHIFT-ENTER, CTRL-ENTER, CTRL-SHIFT-ENTER, CTRL-CURSORDOWN under "Command Line: Keys": http://www.vkta.cz/LANius/diskety/0OSTATNI/FREE/klufa/NC/WINCMD/KEYBOARD.TXT

Tabs are quite useful, too! I guess I'm just too impatient to bother with Explorer ;-)
Matt
Comments are closed.