GEGeek 
   I don't reinvent the wheel, I just link to it.                                                                          Control-F To Search This Page!
Cheat Sheets Search Engines Diagnostics Misc Tech

GEGeek's Articles

Home

Windows

Software

How To Guides

Tutorials

Hardware

Security

Linux

GEGeek Articles

 

 

 

 

 

 

 

 

 

 

 

 

 

 

   
 

The Command Line Part 1 - The Basics  

 

The Command Line Part 1

The Command Line Part 2

The Command Line Part 3

The Command Line Part 4

 

This is not your father's 16bit DOS. This is my first article in the series called "The Command Line". My intention here is not to teach you DOS, but to point out some features and facts about working at the command line that you may not have known before. This could literally be a 10 part series, but I'm trying just to hit the highlights and the most useful aspects of working at the command line that everyone should know. It's assumed that you have had some experience with the command line before, just not enough to appreciate it.

 

Windows GUI

  Windows is widely known for its GUI, but its command line can be a powerful tool for those of you looking to get more precise control and or power from your Windows OS. Many graphical programs you probably paid for and use today simply issue DOS commands and send their outputs back to you in a graphical format. I think if you follow along you will be amazed at what you can achieve via the command line.

 

Windows DOS is not the Old DOS

   Before proceeding further, I wish to clear up a common misconception that the command prompt in Windows XP is the same as DOS. They are not! The old DOS you might have played with before Windows was a 16 bit OS. Windows XP is a 32-bit OS system with a totally different approach. There are some resemblances and some commands with the same name, but all remnants of DOS are totally gone from the Windows XP kernel. The command line in XP has many more capabilities and none of the 16-bit limitations like the restriction to the DOS 8.3 file name format.

 

The Command Box or the Command Window as I like to Call It

  The command box is started by selecting  Start - Run - and then typing in the word "Cmd". This calls the Windows Command Interpreter to be displayed. Note: cmd.exe is located in the folder C:\Windows\System32. You can open several command box windows simultaneously if need be. The Windows Command screen looks just like the old DOS, but it is not. All versions of the DOS commands used here are 32 bits versions of their 16bit counterparts, with much more flexibility and power. The size, shape and color of this Window's command box window can be changed

to suite your needs by right clicking on the menu line and selecting properties. I prefer a yellow text foreground on a black background. Easier on the eyes. That is my default.

 

How To Open a Command Window In Different Versions of Windows

For Windows NT, 2000 and XP type in cmd

For Windows 95, 98 and ME type in command

For ANY Version of Windows type in %COMSPEC%

 

To have the command window go Full Screen hit "Alt+Enter". The same key sequence will return it back to normal.

 

Internal and External Commands

   Their are two types of DOS commands that can be issued within the command box, internal or external commands.

Internal commands are contained within the command interpreter itself. They are known as built in commands.

Commands such as dir, copy, date, move, etc....

Here is a list of the most used internal commands:

 

assoc

dir 

move

set

break

echo 

path

setlocal

call

endlocal 

pause

shift

cd

exit

popd

start

cls

for

prompt

time

color 

ftype

pushd

title

copy 

goto

rd

type

date 

if

rem

verify

del  

md

ren

volume

 

   Therefore, whenever you open a command window, these commands are readily available to you to execute. No matter where you may be within the file system or whatever folder you may be in, these commands will run from there.  These commands can only be run from a command prompt.

 

   External commands can be run from either the command line or the Start - Run line. Only difference is that the command interpreter needs to know where in the system the command resides.  So let's say you are currently in the C:\Windows directory and you issue the command to run an external DOS command, but the external DOS command resides in the C:\Windows\System32 folder. It will not run. Error will say that the program is not found. You need to first navigate to the C:\Windows\System32 folder and then issue the external DOS command from there.

 

   Another way to tell Windows where these external commands reside is through the Path command. When you issue a command to Windows through the command window it first searches through the current directory. If the command doesn't exist within the current directory then it starts to search for the command through a predefined search path. For example. Open a command window and type in "path" and hit return. The results are the path that windows will search through in order to find that command or program name. There can be several defined paths to search through. We'll learn more about the path later. But for now I just want you to understand that Windows needs to know where a command and or program resides if it is going to run it. So we could move all our DOS cmds to a particular directory and then add that directory to the path command and then windows would always look within that directory for the commands.

 

Windows Search Order

  • The current working directory
  • The Windows directory (no subdirectories are searched)
  • The Windows\System32 directory
  • Directories listed in the PATH environment variable
  • The App Paths registry key

 

To see the current Path that windows searches, type in Path and hit enter.

 

 

If you want to add to the path that windows searches you can find out how by asking for help with the command.

You can type any command, a space and a "/?" after it to see the proper syntax for that command.

example: command /?     or     path /?

 

 

How to modify the path environment variable or add a key to App Paths.

HKEY_LOCAL_MACHINE
    SOFTWARE
        Microsoft
            Windows
                CurrentVersion
                    App Paths
                        file.exe
                           (Default) = The fully-qualified path and file name
                           Path = A semicolon-separated list of directories
                           DropTarget = {CLSID}

 

 

 

If you type in  "help" on the command line you can get a complete listing of the available internal DOS commands.

 

 

Just to give you an idea of how many total commands (internal and external) we are dealing with, Microsoft has a listing of them all at:

http://technet.microsoft.com/en-us/library/bb491071.aspx

 

Reference:  XP Dos Commands List

 

Summary - All I wanted to establish today is that you understand that the Window's command interpreter is not the old 16 Bit DOS of days past and that there are built-in commands and external commands. Built-in commands are coded into the Window's command interpreter and that the external commands are 32 bit DOS programs that could be located anywhere on the system, but Windows needs to know how to find them. This can be done either by navigating to that directory and running the command or including that directory in the Window's search via the Path command.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

   
   

hit counter