July 6, 2005
Windows XP isn't known for its powerful command line interface. Still, one of the first things I do on any fresh Windows install is set up the "Open Command Window Here" right click menu. And hoary old cmd.exe does have a few tricks up its sleeve that you may not know about.
The first thing you'll want to do is Start, Run, cmd.exe, then right click the window menu and choose properties. Be sure to enable the following quality of life improvements:
- Options | Command History | Buffer Size | 500
- Options | Command History | Discard Old Duplicates | True
- Options | Edit Options | QuickEdit Mode | True
- Layout | Screen buffer size | Height | 999
- Layout | Window size | Height | 50
Now we've got some room to actually see stuff! QuickEdit mode enables copying from the command prompt by intuitively dragging and right clicking with the mouse. Furthermore, you can paste what's in the clipboard to the command line by right clicking with nothing selected.
And of course, set the font and colors to taste. I use green-screen style colors (background 0 55 0, foreground 0 255 0) with Lucida Console as pictured above. But if you prefer Comic Sans here, be my guest! When exiting this dialog, you'll be prompted to save. Make sure you select "Save properties for future windows with same title" so all future command prompts will benefit from these improved settings.
There are also a few helpful keyboard shortcuts that aren't always widely known:
- Pressing arrow up selects a previous command from your command history; similarly, arrow down selects the next command.
- Pressing F7 pops up your command history list.
- You can drag n' drop files or folders from an explorer window into a command prompt; this inserts the quoted path as if you had manually pasted it.
- Tab completion is fully supported; type edit *.ini then hit TAB to iterate through all matches. Use SHIFT+TAB to move to the previous match. This works for partial filenames as you would expect, and in all commands.
- Tired of the typical "c:\windows\system32\cmd.exe" window title? Change it using the TITLE command.
- ALT+ENTER takes your command prompt to fullscreen mode and back again.
If you're really a hard-core cmd.exe junkie (or maybe a UNIX user), you may want to look into the 4nt command shell replacement. It's a direct descendant of the venerable 4dos shell.
Posted by Jeff Atwood
This is a great. I love cmd and this has really made it even better. There's another shell replacement you may like called cmdow (http://www.commandline.co.uk/cmdow/).
One question, do you know how to make the TITLE persistent? I'll dig around a bit.
Looks like I wasn't using the cmd prompt to its fullest potential. Thanks for the tips, Jeff.
I must admin, I too have the command console setup with green on black.
As it reminds me of my old WYSE PC, with it's green monocrome monitor, where I spent much time writing commands in DOS.
Good tips, I added the 'Discard Old Duplicates' to my cmd settings. I didn't notice that before.
At work I have four non-overlapping command prompt windows at fixed locations on the screen, effectively covering the whole monitor. Then I use the autohotkey utility to navigate between them using CTRL-1, CTRL-2, 3, 4. So I have my main compile/edit window at the upper left, a run window on the lower left, a spare 'utility' window on the upper right, and a miscelaneous one on the lower right. It also to helps to user a smaller font to get more text displayed in a limited space. After you get used to it, you can't live without 'em!
Here's how to add OTHER True Type fonts apart from Lucida console
Notice that the correct registry path seems to be:
(at least it was for me)
Is there a way to set the buffer height during invocation?
FYI, XP Pro Service Pack 2 had it in a different location:
hey can you follow up on hawks5999's question on how to make the title persistant. It would be a big help! Thanks your neighborhood pyro freak
Thanks, this is fantastic it has improved my usage of the cmd line. I'm still searching for a kde konsole like tabbed interface if anyone knows of one.
Easy way to have a personalized Title:
On the desktop (or wherever you feel like), create a new Shortcut that leads to the command promt. Name it whatever you like,and thats what you get for Title every time you use that.
I've used "Nihongo Yet Another OSes Shell" for OS/2 for years. They also have DOS/win9x AND WinNT/2K/XP versions. Open Source. Highly configurable...
I have a new XP laptop to replace my old one. For some reason, I can't use the up arrow to scroll through previous commands. I've been searching for a way to turn that on. Can you help with that.
Good stuff here. I'll have to try this on my home computer. I'm in computer class right now at my school and i got cmd running out of boredom (even though technically it's blocked from running on this computer i got the admin password and yea...)so thanks ^^
I found some interesting tips here, but have come across a puzzle when using the command prompt.
If I execute any of the old DOS commands, it changes the current prompt with long directory names to use only short mangled directory names.
Any ideas on how to restore the long filenames
Norman, sometimes I see windows XP machines where command completion is disabled. Here's how to enable it:
Also, try checking the help for CMD, eg:
.. it's actually very informative.
you guys have any idea where is the list of programs which run when executing cmd.exe located? every time I type "cmd.exe" I get an error aboute some obscure dll file which even google does not know...
My "dir" command doesn't work. I'm running XP. This is at work. I've had people tell me it's in my "rights". Where are those and how do I change them? Any help with this would be great.
How do we change what sub directory the command prompts goes to when first opened.
i wanna know how to change directories with
names like "mysql server" or "12345.0"
in command prompt
Easiest way to get persistant title and colors: Go to start, programs, accessories, then dragdrop the Command Prompt shortcut to somewhere on your desktop. You can rename it to get the title, right click-properties to change the color and stuff. When you open that shortcut, the colors and title should be the same
hey man, i'm a system administration student, and you just made my life a whole lot better with these tricks... no more boredom!
Persist the title?
The following, which if merged, puts a "Command Prompt" item on the Folder context menu, will set the title to the path where window was opened. It also makes that folder "current" and loads some DOSKEY macros. (The "doskey /insert" may be a holdover from earlier OS versions. Not sure it is necessary in XP.) I have also executed batch files from this command string which can do whatever batch files can do. The ampersands allow you specify more than one command on a single command line. They need to be doubled up in batch files and scripts like this.
Windows Registry Editor Version 5.00
@="C:\\WINNT\\System32\\cmd.exe /k cd \"%1\" doskey /insert doskey /macrofile=c:\\bat\\doskeymacros.mac title %1"
I would like to know how to make the shell window like other xp windows. I have a program(tweakwindows) that I downloaded just to keep my cmd.exe "always on top" but it seemingly only works on the fancy xp style beveled windows.
is this possible?
Make the title persistent??
Set the Environment Variable %comspec% to the title you want, done.
one way it seems to be possible is to make a shortcut to it then right click and select properties and type the sub directory in the start in box
Hey there. I'm new to CMD and got to working on it when scheduling a weekly defrag on XP, but when my defrag gets done running the screen automatically closes. Is there a way to make it not close? I also wrote a cmd for defrag c: -a so I can see a report, but it to runs the analysis and immediately closes. Thanks.
HOWTO: Execute any command "initially" when opening up a Commmand Prompt Window.
1) Create a Batch file with the commands that you want executed at the time of the command prompt being opened. Save this Batch file in a location that you won't delete (My Documents,etc)
2) Then open up regedit, and add that batch file to the following Registry entry.
There's a variable called AutoRun.
Right-click and Modify
Add the path to your batch file in the Value Data field: (enclosed in Double-quotes)
3) Now go start a command-prompt, and watch it execute this batch file every time.
I use mine to set my initial directory, and execute ipconfig.
Also, this DOES NOT affect the Windows PowerToy "Open Command Window Here". Your batch file will run (and change directory to your specified one), and then the command prompt will switch to the directory that you right-clicked on for the "Open Command Wnidow Here" action.
there is a Sourceforge project with a tabbed console program...
do a search for it.
Do any of you know how to change your desktop background by using cmd.exe because they have blocked the Control Panel and the "right click set as desktop background" buttons at work??
i wanna make 2 batch files that send messages to eachother at set intervals and when one of the batch files is X'd out and stops sending messages ot the other, i want the other to know that and then shut the computer down how would i write this?
Question since you know what your talking about...
How do I make new variable with the set variablename command that will execute 2 commands for example
set mouse=(time ipconfig)
??not sure ive tried the above example and no luck any ideas are greatly appreciated
As Norman said: I have a new XP laptop to replace my old one. For some reason, I can't use the up arrow to scroll through previous commands. I've been searching for a way to turn that on. Can you help with that.
My computer doesn't do this for some reason, either. Really annoying. Any help?
NORMAN / ALHEIM :
I found the answer (to my own question). :
On any Windows version but XP, enter the command doskey. This causes all subsequent commands you type in to be saved, and you can navigate backwards and forwards through these saved commands by using the up arrow and down arrow keys on your keyboard. Windows XP doesn't require doskey—the feature is turned on automatically when you open a command-line window.
Basically, type 'doskey', and your problem is fixed. Whew.
i just got a new windows XP computer. i have it set so when the screen saver turns on, it atomaticly promts for the owner password. i was wondering if there is any command that you could enter into command promt that would show that password. i dont want it changed i just want to view it though. if there is could you email the command to me? my email address is email@example.com
thank you very much
How do you do 'Program Files' i cant get the space between program and files is it like %20? coz i tried that
to change to a directory with a space in the name, surround the dir name with quotes, like this: cd "a bad folder name"
another option for the above folder would be to type cd a and then hit tab and it will auto-complete the quotes and the rest of the folder name
How do I keep a cmd window open? I do lots of cisco commands in the command window and it sucks if I accidentally click it closed. I want a prompt or something to stop me from just clicking a window closed.
The instructions on adding additional true type fonts to the command prompt reference a link no longer contains instructions. Could someone
post the instructions here?
I know I can set peristent window title using "title" command. How can I read the currently displayed title of the window?
I'm a devloper of over 10 years experience, and shamefully I either forgot about the F7 command, really handy when working with Mysql commands when you've just changed one and have been pressing the up key repeatedly.
Anyone know of a command that you can enter in command promt to make it fullscreen. (I.E without the use of Alt+Ent or shortcuts or other software.)
anybody know of a way to save/restore a Title
TITLE Come back soon - I am busy now
ALT key + space bar
might be of use
it will maXimize the window, which, while not FULLscreen, is still a bigger screen than the default size.
Anyone know how to set the default path that cmd starts you in? I know with a shortcut you can set the path, but for launching the shell via start, run, cmd how do you set that?
K so I downloaded your little script thingy for the right click, reset the window settings and then went to right click on the body, and got a bunch of errors pumped out.
Now my computer is incapable of opening any .exe file with the mouse, I have to open everything through the task manager.
Yes! I love this.
Hey, my shutdown command isn't working. It says that "shutdown.exe is not a valid Win32 application." and it is really starting to bug me that i can't shutdown through the command prompt. if anyone can help me out, email me at firstname.lastname@example.org thanks
I'd like to know the answer to Ken's question above!!
How do you set the default path that cmd starts in?
To change default path where cmd starts add/edit REG_SZ Autorun in
HKEY_CURRENT_USER\Software\Microsoft\Command Processor replacing the Value Data with a folder or directory preceded by a CD\.
I find that use can just type "title" space "the name you want". It'll change the title.
i was just wondering if any of you know how to change an administrator's password with the command prompt
in order to change the administraters password you have to type in this command.
net user administrator ( if ur on an administrator's account)
net user owner ( the one you use if ur on a non admin. account)
now type in
net user admin,/owner which ever you are on
with a * after it
so it looks like this:
net user owner *
then u just type in the password twice and bam...deletes it and changes it to the one u want.
Go to notepad. Type in:
and save it as " cmd.exe.bat" Now run :P
That seems kinda convoluted.. when I want to change a password in DOS I just type:
net user username password
..and it sets it.
Anyone ever notice if you set an autorun to cd\whatever so it starts in the folder you want, it does it even for FOR loop processing? That's kind of annoying. I.E. if I have an autorun that is cd c:\windows then I jump to DOS and I'm in C:\WINDOWS then go back to root if I do for /f %s in ('dir /ad /b') do echo %s instead of getting the C:\ subfolders I get the C:\WINDOWS subfolders.
I dunno if there is any way around that, but it's annoying nonetheless.
not bad. still not quite there with a bash prompt, but getting better. tab completion seems a bit sucky (it guess wildly at the first thing it sees, and doesn't seem to work across drives for me) but this is a help.
might have a look at that 4nt thing.
To keep the title, Type the whole command in a text editor, then save as... and click 'all types' in the file type dropdown, leave the encoding and type 'Command Prompt with Title.bat' or .cmd or any name before .bat/.cmd. Then you just run that each time and it will run the script.
You can do this with any script, say you wanted to renew your IP frequently, you'd type the following:
and save the file as all types as 'Renew IP Address.bat'
Run it and it will do it all and exit as if it was a program (a cheesy one).
You can access command prompt even if your edministrator has blocked it. access it thrrough notepad by running notepad, then typing 'command.com'. Save the file as 'command.bat' . Go to where you saved this file and open it. It should run command prompt. If you administrator has blocked notepad, go onto any website and rightclick the backdrop to the website (not a link or anything) and select something that should say something like 'view source text' this will run notepad. Hope this helps some people!!!
Somehow, someway, my XP command prompt will not allow any of the "up-arrow"/"down-arrow" functions. I am not sure how to turn these on, as I have tried all of the different settings, including Quick Edit=ON, but nothing has worked.
You are truely god among me right now Mr. Jeff Atwood.
Working with Mysql will not be such a pain in my butt. Thank you, so very much.
Hi guys, I was just doing this for a relatively new XP machine. At work on my w2k machine I somehow was able to add two "command prompt here"s (well, it's just an entry on the Directory/Folder class) with *different* settings. I tried a few things but couldn't figure it out and so I came in to work this morning and checked how I did it. Here's how you do it. Change the shell command for your Directory/Folder class (at home Command Prompt Here has registered it on Directory, at work it's on Folder, go figure):
cmd /c start "Command Prompt (large)" cmd /k cd "%1"
This may or may not instantaneously open an initial command prompt. If it does, it happens so fast I cannot tell. I also tried the /b flag on cmd as I recall vaguely that that option prevents spawning a new window (although I have no idea whether that implies not spawning an *initial* window). In any case I can't tell the difference. You can add as many of these as you like with different titles and then "Apply properties to windows with same title" to have distinct, persistent, settings.
To add to PERSISTENT TITLE thread. Here is a trick that I use.
Execute the bat script (below). When the shells open for the first time, resize, position, change colors etc for each window. Uncheck 'let system position window' (in properties - layout) and 'save settings for windows with same name'.
Now, when script is executed again, all the consoles pop in the right place in different directories, colored, titled, and with custom prompts!
start "Server" nbsp;nbsp;nbsp;/D[c:\...] cmd /k "prompt $_Server$g"
start "Source" nbsp;nbsp;nbsp;/D[c:\...] cmd /k "prompt $_Source$g"
start "Unit Test" /D[c:\...] cmd /k "prompt $_Unit Test$g"
Now, what I really want is systax highlighting in the native windoze cmd shell. Anyone got a lead on that?
With regard to setting the shell window title after already launching the shell: yes, this can be done, but if your intent is to load all the shell configuration (color, size, font, etc., when prompted to save changes to "All windows with this title"), I believe the title needs to be set *before* the shell is actually launched. Just doing something something like 'title "my title"' will surely set the title, but won't automagically load all the console settings associated with that title. Maybe this can be done with the comspec var, but that would have to be set in the invoking shell (I presume), so I'm not sure how that would happen.
Wow, that Console program from SourceForge kicks ass. No more screwing around with registry settings. Thanks!
What I'd like to know is, where are all these CMD settings saved?
Click the QuickEdit checkbox, OK, choose 'Apply to all future windows' etc. and it all works...but where does this settings change get stored?!