Useful Keyboard Shortcuts for the DOS Command Prompt in Windows

command-prompt-shortcut-keys We look at some useful keyboard shortcuts and commands that will help you personalize the MS-DOS Command Prompt Window without using the mouse.

You will also learn about hotkeys for executing DOS commands more quickly. The keyboard shortcuts are known to work in Windows Vista and XP command prompt.

1. Change the color scheme of the DOS Window

dos color shortcutcolor bf - where b is the background color while f is for the foreground color (they are hex codes).

For instance, if you want to have a white background with black text, type color F0 and press enter. To revert to the original color scheme, type color without any arguments.

For a list of all available colors, type color /? on the command line.

2. Chant the Title of the Window to reflect the current time

dos-title-command

Do you know that you can put your name or your blog address in the title of the command prompt window. That’s like a neat watermark when you are using that screenshot for your website.

title your_name  %time%

That %time% will append the current timestamp to the Window’s title.

3. Navigate the Command History using Keyboard

If you have a long list of commands in the history, press the function key F7 to navigate through the history list using the arrow keys.

And if you already know the command number, press F9 and directly type that number. Very useful if you have to run some command repeatedly.

dos-command-history

4. Typing Long Commands at the DOS Prompt

You know the frustration when you type some long command only to realize that you made a typo or omitted typing some character. Either type the whole command again or a better option is the F1 key.

f2-dos-command F1 prints characters of the previous command one by one

Alternatively, you can press F2 to copy a certain number of characters from the previous command to the current one. Let me illustrate that with an example:

Say I want to run the command “nslookup www.google.com” but wrote “nslookup www.googlx.com” in a hurry.

Instead of retyping the whole thing, I can say F2 and then say x. This will print all the characters upto “x”. Then you can press F3 to complete the command or type it manually.

Related: Copy Command Line Output to Clipboard

Find this article at: http://www.labnol.org/software/tutorials/useful-keyboard-shortcuts-for-the-dos-command-prompt-in-windows/2629/

Tags: , , , , , Software, Tips, Tricks, Tutorials

Reader Comments

Wow these are great I never knew about the F7 and F2 trick, this will definitely come in very useful for me.

The F7 trick extremely useful.
You’re a real life saver, Amit :) Thanks

Great tips never knew these ones.

excellent, i never knew about these…

you should write about tab completion, i bet not many people use that feature. when typing in long file names, hit tab to auto-complete.

Also try F8 which cycles through already typed commands, kind of like Doskey,

“2. Chant the Title of the Window to reflect the current time” Should this be “Change …”? Sometimes chanting may be the only way to keep computers working … Many thanks for the tips!

Something I found the other day as an alternative to F7:

doskey /history

It brings up the same list but in an easily cut-and-pasteable form.

It should not be called the MS-DOS command prompt, because the system is no longer called MS-DOS. It has not been MS-DOS for over ten years now.

It is the (Microsoft) Windows command prompt.

This only works for 1 session, when I close cmd and then reopen it is back to white on black.

Jim

I find that it’s much more useful to set the time with the prompt command, since the window’s title is only updated once.

For example, I run the following for my command prompt:
prompt $c$d$s$t$f$_$p$g
title %username%@%computername%

Which produces a prompt that looks like this:
(Fri 03/21/2008 20:25:30.40)
C:\>

Far more useful IMHO.

@Jim
You need to create a batch file that runs the commands for you, then launch cmd.exe so that it calls this batch file first.

For example:
cmd.exe /k “H:\customprompt.bat”

So how about F3 to repeat the last command.
comes in real handy for pinging a lot of different IP’s . just change the last number before hitting enter.

Hey how come I never heard of F7 and F2 shortcuts before :?
Thanks for great tip. :)

1.how to format removable flash disk using dos command
2.how to delete one item in a removable flash disk using dos command
3is it possible to scan virus in flash disk using dos command ?

use the up arrow at cmd prompt, much much more quicker

Hi,
if you want to copy a command from other window to the command prompt(which is not in full screen). just copy the text by Ctrl+C and right click in the command prompt it will paste the text which is in the clipboard..

my f8 key is not working give me substitute key for that.

Hi all, can someone please tell me how to get from C:\users\wes to C:\
I am using Vista and this is what I get when I open my DOS prompt. It actually says Administrator:Command Prompt at the top of the prompt box.

Many thanks for the help I know I will recive Waz

Can anyone tell me how to delete a virus using command prompt

When am tryin to change the path it is not beig changed…For example my path is set as c:\documents and settings\destop\priya
if i want to change as c:\program files it does not change.what should i do for that to change?

hye priya…
for changing path you first write cd and then the file name or else u can create a batch file at
c:\documents and settings\destop\priya
this location with following content
cd\
cd c:\program files
then save it as “d.bat”
now when u open cmd just write d and hit enter…

Hey Wez Did you ever get to know how to delete a virus manually?
Sorry I have come in four months down the line are you still on?
may be we can share the little knowledge I gut

Hi,

I’m a new IT student and need to know the following:

On the Ms-dos command prompt screen.

1). Change the drive to hard disc. Is this [C:\>] ?

2). Issue the command that enables you to change the date.

3). Steps to follow to change date.

4). Issue the command that enables you to change the time.

Thanks!
Chris..

Hi there.I was surfing the net that I encountered your website.I hope you can help me.I am having a problem with my windows xp.As you know the “search” and “Run” options are in start menue but I cannot see them, why?where they have gone?
besides the “command prompt” option in accessories does not work.what’s the problem?
Regards.


Comment

Google Custom Search