Quote of the day : "The wise man shuts his mouth and makes people think he's stupid, while the idiot opens his mouth and removes all doubt." Lord_Aba

Next quote in 0.8 hours. [suggest a quote]

Using the command line

Related book
Using the Command Line in Windows 2000 Professional

by Carolyn Z. Gillay, Bette A. Peat


  • To run the command line, run cmd or command.
  • The main browsing commands are cd and dir, but you can list all the commands by typing help, and learn how to use them by typing help command_name or command_name /?.
  • To send data/parameters to a command line based application, you'll have to use commands like c:\full_path\the_application.exe -core( -input "file.mp3" -output "file.ogg" ) -ogg( -q 0.100 ), which you can put in and run with a batch file.

Why ?

Some softwares (mostly freewares) don't have a Graphical User Interface (GUI), because this implies a lot of work, and many programmers prefer to focus on the "real" programming (I mean, working on a GUI is boring).
The problem is that in order to get this programs work, you have to remember some basics of our old DOS. Not many in fact.

How to... launch the command line

→ In the Start menu, choose Execute (you can also press windowskey+F).
→ Type command or cmd and press OK.
→ Welcome (back) to DOS ! Hm, in fact this is not at all the DOS, it just looks like it. This is a command line, in which you can use some DOS command. Here is what you should get :
Command line screenshot

→ To close the command line, type exit.

Note : about 8-characters names

If you launch command.com instead of cmd.exe, you'll have to use 8-char names : eg, a file named black adder.txt becomes blacka~1.txt (note that all spaces are removed).
If there are several files starting with "blacka", then they are named after their alphabetical order, eg, if you have myname_is_what.txt and myname_is_who.txt, myname_is_what.txt should be referred to as myname~1.txt and myname_is_who.txt as myname~2.txt.
You may also have to/want to use this 8-char denomination when manipulating long filenames or filenames including spaces.

How to... browse your computer

When you launch the command line, you get into your user folder (c:\Documents and Settings\Administrateur on my screenshot above).
→ To go to the parent directory, type cd.. (cd{dot}{dot}).
→ To go back into your user directory, type cd your_user_directory (for me it's cd administrateur).
→ To go to the top directory, you could type cd.. as many times as needed, but you can also type cd\ to go directly to the top. Let's see where we are now :
Browsing screenshot

Well, now let's find out what is in our c:\ directory :
→ To list the files of the directory you're in, type dir. You're likely to have too many files to fit in your screen. Since you are on Windows, you can use the scrollbar to see the whole list. But this is not how an advanced user like you ;) should do : to display the files page by page, type dir /p. Here is the result :
Directory listing screenshot

→ To display also the hidden files, type dir /a.
→ To display also the hidden files, and page by page, type dir /a/p.
→ And... to view all the options around dir, type dir /? (or help dir) and read ! :)

To learn more about the commands, just type help and if you read it all, you'll know (a lot) more than I do !

How to... run an application and send it parameters

Let's try and launch some application :
→ Type ping and press enter. This launches the ping.exe application.
→ The "proper" way to launch it would be to type its full path (eg, c:\winnt\sytem32\ping.exe if you have Win 2k or XP - try it, or c:\windows\sytem32\ping.exe on win 95/98/Me - note : we'll use this "proper" way to launch other applications like BeSweet), but since it is a particular system application, typing ping is enough.
→ Here is what you get :
Ping screenshot

→ So... it didn't do anthing, for it needs paremeters. You cannot launch the program and enter the parameters then (as you do with a program having a GUI), you have to send them to the program when you call it (Note : the program echoes some help on how to send the parameters to it, this often but not always happens with command line based softwares). Now let's tell the program what we want. We want to ping yahoo, for instance, so we type ping www.yahoo.com. If you are not connected to internet, you'll just get a "host unknown" message, otherwise you'll get this :
Ping yahoo screenshot

→ You can do it "the proper way" :
Full path ping yahoo screenshot

Batch files

Finally, we'll learn how to use DOS commands without the command line utility :
→ Open notepad (or execute notepad : windowskey+F, and type notepad).
→ Type the command "the proper way" (eg c:\winnt\system32\ping.exe www.yahoo.com).
→ Save the file as somename.bat :
Batch test

→ To run your command, just double-click on the batch file :
Batch test.bat
Comments :
No comments yet
[Add a comment]