Using the command-window in Windows

Okay youz, I’m posting this here so that you have a place to go to get a few basic elementary questions answered regarding your DOS Command-Line. I guess it shouldn’t seem surprising that these past years of working within the Windows GUI has left some without any familiarity with that good-ol DOS prompt.

Your going to need this for some things in the course of your software development work if you’re using C or C++, Java, and even for some .NET tasks.

So what exactly is it?

Well, let’s start off by showing you what it looks like..

The default command-line window

Back when we bought our first 8088-based IBM Personal Computers, the operating system was simply “DOS”. It was Microsoft DOS, or IBM DOS depending upon where you picked it up. But that is pretty much what it gave you – a terminal screen with lines of text. 25 lines, with 80 columns. Without the window of course. That “C:\>” with the fat underscore after it (it was blinking) was referred to as your “DOS prompt”. This is essentially just a text-based terminal window. Now, within Windows you can access this by clicking on “Start”, then selecting “Run…”, and within that “Run” dialog you enter “cmd” and then click the “OK” button (or just hit the Enter key).

What you have now, is a terminal-window packaged within a Windows window. You type in your “DOS” commands and press your Enter key to make them execute, just as you (ahem) did back in the days of DOS. For brevity let’s refer to this as the “DOS Window”. To see a list of files in the current directory, type DIR and then hit the ENTER key. These commands are not case-sensitive. To change to a different directory, type CHDIR and the name of that directory and then ENTER. Etc, etc. We won’t cover how to use all the DOS commands here. When you’re done you can get rid of this thing by entering the EXIT command, or by simply closing the window.

It’s still a useful mode to work in when you’re tinkering with, for example, Java, or some of the Windows command-line utilities, or F# (you Unix fellows go play somewhere else right now. We’re busy).

Okay, let’s spruce this up just a tad, shall we?

If you’re like me, you like lots of space to see what you’re typing in. So let’s expand this a bit..

Click on the little icon at the upper-left corner of the DOS Window to drop down the “System” menu, and select “Properties”. Here’s what it should look like..
The System-menu

This should bring up the “Properties” dialog. Select the “Layout” tab, and here set your desired Screen Buffer and Window Size. Since I find the original too limiting, I generally make these settings larger. For example, under “Screen Buffer Size” try setting the width to 160, and under “Window Size” set it’s Width to 160 also plus set the height to 66. I use a 30″ display, so you may need a smaller size-setting. You can also change some other settings here. For example, just for giggles – select the “Colors” tab, click on the “Screen Text” radiobutton, and select a different color – I put mine to green (Red 0, Green 255, Blue 0). Then click on the “OK” button when you’re done.

Your DOS Window now resembles the old green displays we had in the IBM-PC days.

Add a DOS-window option to Windows Explorer

As a convenience, let’s add an option to our Context-Menu within Windows Explorer to open a command-prompt window that starts at the selected folder, shall we?

There’re a few ways to accomplish this. Let’s make a setting within the Windows Registry for this, since you can cause all sorts of mischief if you screw this up.

under Windows 7 1. Open REGEDIT by clicking on the Orb (Vista or Windows 7), and enter regedit in the run-box.

Under Vista or Windows 7, you may get tripped up by lack of administrator rights. You may be able to open REGEDIT, but you may not be able to add any keys. To circumvent this annoyance run it as Administrator. Here’s how..

Go to that Run Box, type in your command (regedit in this case) and instead of hitting ENTER, press CONTROL + SHIFT + ENTER. Windows will present you with that User Account Control dialog, but after that it’ll run your program in Administrator mode and you’re in.


2. Within REGEDIT, Click to open HKEY_LOCAL_MACHINE, then open these others within the tree..

SOFTWARE / Classes / Folder / shell

When you open Classes, you’ll have to scroll down quite a ways to get to Folder.

Note: On my Thinkpad, I didn’t see Folder under HKEY_LOCAL_MACHINE. So I went under HEKY_LOCAL_USER and navigated to Folder under there. There was no shell key; I had to create it.  It still worked.

3. Within the shell key, create a new key and name it “Command Prompt”. Without the quotes. Set the default value to whatever text you want o appear in the context-menu. I put “Open DOS window here”.

Note: If you don’t have Administrator rights, this is where you’ll get that MessageBox saying “Error Creating Key” blah blah.. See tip above to get around this.


4. Within this new key (“Command Prompt”), create a new key and name it “command”. Set the default string in this to:

cmd.exe /k pushd %1

Note: You might need to add %SystemRoot%\system32\ before the cmd.exe if the executable cannot be found when it tries to run.

The change should take place immediately. Go ahead and open Windows Explorer and right-click on a folder to get the Context-Menu. Your new item should appear.

Here's what it should like like.


James W. Hurst


About James W Hurst

a professional software designer since the beginning days of the desktop cptr and uC-controlled avionics, I today am focusing on Java, Swift, C# and F# for building mobile and desktop and online applications under Android, Xamarin.Forms, iOS, WPF, and ASP.NET-MVC along with the requisite HTML/CSS/JavaScript/Ajax for web applications. My database expertise has covered a panoply of different database-engines and modeling approaches, and my main area of academic interest is Artificial Intelligence and vision.
This entry was posted in Microsoft Windows tips and techniques and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s