in4mation ... organized

Is cmd.exe and command.com the same ? Part I

Page 1

Article by: Pramod S Nair written for www.wisdombay.com

Basically when we glance at the black screen thrown at us by Windows boxes when command.com or cmd.exe is executed, they look the same. But cmd.exe which is the command prompt in Windows 2000/XP/NT is far superior in performance and the power that it packs than command.com.

The most important difference is the added feature by which cmd.exe stores the history of all commands executed in a command session. It is a nifty add-on, which can be of a great blessing when you are forced to work a non-GUI way extensively. You can track back to the very first command issued by you in a session using the up-arrow key on your keyboard and can traverse through the whole array of commands used in a session using the arrow keys.

In this article which we will take a journey through some of the features offered by cmd.exe

Utilizing the Switches

First let’s have a look at the various command line switches available to ‘cmd.exe’.

  • /C Switch :

                Think of a situation where, you need to execute a command just after loading ‘cmd.exe’, you can go for this command line switch. This switch loads a session of ‘cmd.exe’ into memory, executes the command specified after /C and terminates the cmd session.

Ex : cmd /C dir    

                This creates a new command session and executes the command dir in the new command session. After execution the new session terminates.

  • /K Switch :                

                This switch is the same like /C, but after completion of the command the session is not terminated.

Ex : cmd /K date 

                This creates a new command session and executes the date command, the session is not terminated after completion of the command.

  • /Q Switch :

    This switch is handy if you want to turn off the echoing property of  command line. After Launching a command line session with /Q switch ensures that all commands from batch files are run without them getting echoed on the screen.

    Ex : cmd /Q

  • /A Switch :

The /A switch of cmd.exe ensures that all redirected or piped outputs from the current session is in ANSI.

Ex: cmd /A 

Now this instance of command prompt will ensure that all redirected outputs are of ANSI in nature. To test this run a dir command and redirect the output to some file.

  • /U Switch:

    This ensures that all outputs from a command session is redirected as Unicode.

    Ex: cmd /U

    Now run the same test that we did at the cmd /A example. If we compare the two files generated from the /A and /U examples, we can find that the file generated by the /U session is a bit more large as it is encoded in Unicode.

  • /T switch :

    This switch lets you add color to your black and white command line world. The switch is used in a format like cmd /T: forecolor/backcolor.

    Ex : cmd /T:F0

    The above command will make the current command session in to a window with white background and black foreground color.  

There are a whole lot of other command line switches also for cmd.exe. We will be dealing with them in the next issue of this article.