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:
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:
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.
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.
Alan Le on July 11, 2005 2:24 AMI 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!
thedisciple on July 12, 2005 5:13 AMHere's how to add OTHER True Type fonts apart from Lucida console
a href="http://toponcefamily.com/blogs/aaron/archive/2005/07/21/707.aspx"http://toponcefamily.com/blogs/aaron/archive/2005/07/21/707.aspx/a
Notice that the correct registry path seems to be:
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/Console/TrueTypeFont
(at least it was for me)
Enjoy!
federico stafforini on August 7, 2005 2:13 AMIs there a way to set the buffer height during invocation?
Andy on September 16, 2005 9:34 AMFYI, XP Pro Service Pack 2 had it in a different location:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont\
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
pyro108 on December 12, 2005 8:32 AMThanks, 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.
Eugene Liedel on March 22, 2006 10:41 AMEasy 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...
http://www.nyaos.org/index.html
Glenn on April 22, 2006 5:48 AMI 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.
Norman on May 8, 2006 9:20 AMGood 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 ^^
laura on May 22, 2006 8:47 AMI 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
Bill on June 10, 2006 5:09 AMNorman, sometimes I see windows XP machines where command completion is disabled. Here's how to enable it:
http://www.winguides.com/registry/display.php/3/
Also, try checking the help for CMD, eg:
c:CMD /?
.. it's actually very informative.
Jeff Atwood on June 10, 2006 6:34 AMyou 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...
tnx,
ljuti
Hello
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.
Stephen sag@co.clark.nv.us
Stephen on June 13, 2006 2:35 AMHow do we change what sub directory the command prompts goes to when first opened.
Thanks.
The_3_Little_Pigs on June 13, 2006 6:15 AMCheck out here:
http://www.winguides.com/registry/category.php?180
Plenty of good ideas
Carl B on June 16, 2006 11:37 AMi 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
Anonymous on July 7, 2006 8:31 AMhey man, i'm a system administration student, and you just made my life a whole lot better with these tricks... no more boredom!
richie on July 8, 2006 4:30 AMPersist 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
[HKEY_CLASSES_ROOT\Folder\shell\Command Prompt\command]
@="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.
We still weren't able to find out how we can change what sub directory the command prompts goes to when first opened.
We did go here but found nothing:
http://www.winguides.com/registry/category.php?180
Thanks.
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
Mike on August 2, 2006 8:28 AMHey 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.
Craig on August 12, 2006 2:31 AMHOWTO: 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)
such as:
cd /profiles/username
ipconfig
ping google.com
2) Then open up regedit, and add that batch file to the following Registry entry.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
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)
"C:\Profiles\username\My Documents\cmd.bat"
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.
@Eugene Liedel:
there is a Sourceforge project with a tabbed console program...
do a search for it.
:)
Jonny on August 14, 2006 9:45 AMDo 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??
Thanks
ComputerGeek on October 30, 2006 8:47 AMhttp://sourceforge.net/projects/console/
Get the latest beta version, it's fine.
Julian on November 8, 2006 12:52 PMhey
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 variablename=mouse
set mouse=(time ipconfig)
%mouse%
??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?
Alheim on January 5, 2007 4:25 AMNORMAN / 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.
Alheim on January 5, 2007 4:33 AMhey
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 yrttw4@aim.com
thank you very much
bryan
How do you do 'Program Files' i cant get the space between program and files is it like %20? coz i tried that
Tim on January 23, 2007 1:31 AMto 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
Joe on January 25, 2007 11:30 AMHow 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.
kenscottii on January 27, 2007 7:34 AMThe instructions on adding additional true type fonts to the command prompt reference a link no longer contains instructions. Could someone
post the instructions here?
there is a really cool command line tool that came out for vista called power prompt. they released it for XP SP2. you can get it here:
http://www.microsoft.com/technet/scriptcenter/topics/msh/download.mspx
there is another site that talks about the powershell for xp here:
http://commandwindows.com/powershell.htm
john
www.datahacktechnologies.com
I know I can set peristent window title using "title" command. How can I read the currently displayed title of the window?
KMR on March 15, 2007 10:57 AMI'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.
Paul M on March 20, 2007 8:45 AMAnyone 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.)
Nick on March 29, 2007 8:52 AManybody know of a way to save/restore a Title
PUSHtitle
TITLE Come back soon - I am busy now
DoMyThing
POPtitle
ALT key + space bar
then "X"
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?
Ken on May 4, 2007 2:35 AMK 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.
:/
ate on May 4, 2007 9:00 AMHey, 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 thor792@hotmail.com thanks
Kevin
Kevi Brookes on May 6, 2007 1:25 PMI'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\.
Have Fun
XsokolX on May 26, 2007 4:24 AMI find that use can just type "title" space "the name you want". It'll change the title.
Ninja36036 on July 25, 2007 9:58 AMi was just wondering if any of you know how to change an administrator's password with the command prompt
that one guy on July 27, 2007 11:18 AMin order to change the administraters password you have to type in this command.
net user
then either
net user administrator ( if ur on an administrator's account)
or
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.
=)
tyler on August 5, 2007 9:23 AMGo to notepad. Type in:
@echo off
start "command.exe"
and save it as " cmd.exe.bat" Now run :P
Shortone on August 24, 2007 4:18 AMThat 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.
Ken on August 28, 2007 11:40 AMnot 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:
ipconfig /release
ipconfig /renew
exit
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).
Danvds3 on September 12, 2007 9:04 AMYou 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!!!
Zedoo on October 10, 2007 3:13 AMSomehow, 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.
Any suggestions???
Scott on October 16, 2007 12:48 PMYou 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.
Cliff on October 29, 2007 10:43 AMPERSISTENT TITLE
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.
Aaron on February 6, 2010 9:30 PMGood Stuff.
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"
exit
Now, what I really want is systax highlighting in the native windoze cmd shell. Anyone got a lead on that?
John Sampson on February 6, 2010 9:30 PMWith 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.
Aaron on February 6, 2010 9:30 PM@Jonny
Wow, that Console program from SourceForge kicks ass. No more screwing around with registry settings. Thanks!
Aaron on February 6, 2010 9:30 PMThe link to OpenCommandPromptHere.zip appears to be dead.
This site has various methods of achieving this functionality:
http://www.petri.co.il/add_command_prompt_here_shortcut_to_windows_explorer.htm
cbserra on May 16, 2011 11:00 AMWhat 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?!
Jpjeffery on August 19, 2011 4:04 AMThe comments to this entry are closed.
| Content (c) 2012 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved. |