Command (& Exit)

Index

Starts a new copy of the Command Interpreter.

Syntax:

COMMAND [path] [device] [/Switches]

pathDirectory (and drive) containing command.com. This must be specified unless command.com is in the root directory.
deviceDevice to use for command input and output. By default this is the keyboard and monitor.
/PMakes the new Command Interpreter permanent.
/E:xSets the initial environment size [bytes]. x should be set between 256 and 32,768 bytes. The default is: 256 bytes.
/L:yInternal buffers length [bytes]. y should be set between 128 and 1,024 bytes. The default is: ? This switch is only accepted if the Command Interpreter is permanent - ie. the /P switch must also be set.
/U:zInput buffer length [bytes]. z should be set between 128 and 255 bytes. The default is: ? This switch is only accepted if the Command Interpreter is permanent - ie. the /P switch must also be set.
/MSGStores all error messages in memory. This switch is only accepted if the Command Interpreter is permanent - ie. the /P switch must also be set.
/LOWForces COMMAND to keep in low memory
/YSteps through the batch program specified by /C or /K
/C commandExecutes command and exits. This must be the last switch on the command line.
/K commandExecutes command and continues running. This must be the last switch on the command line.
/FForces a "Fail" response to the Command Interpreter's error handling routine query: "Abort, Retry, Fail?".
/ZCauses the ERRORLEVEL number returned by external DOS commands to be appended to the command's output.

Notes:

  1. Every time a Dos window is opened in Windows95, a new (non-permanent) instance of the Command Interpreter is run. Thus several instances of Command.com can be running independently at the same time.
  2. The EXIT command is used to quit any non-permanent instances of Command.com.
  3. Under normal circumstances, the only occasion when the /P switch need or should be specified is when Command.com is used within a Shell statement.
  4. The /MSG switch is quoted as forcing all of Command.com's messages to be loaded into memory on startup. This could save a bit of disk swapping if the machine is running from floppies However, as Dos7 only runs on machines with lots of memory it would seem to be natural for this to be the default. Indeed, when I tried loading Command /p with and without the /MSG switch, both versions were reported to be using exactly the same amount of memory implying that this switch is now redundant.
  5. The /Y and /Z switches can be particularly useful in helping to debug macros and would typically be used in conjunction with the /C switch. Once the macro was working, the /Y and /Z switches would probably be dropped and the command line assigned its own shortcut.

    The /Y switch steps through the macro line by line and gives the choice of processing the line or skipping it. This example is from a fragment of a batch file. The operator is escaping from a loop by not processing a GOTO instruction:

    ........
    C:\WINDOWS>shift
    shift [Enter=Y,Esc=N]?Y
    
    C:\WINDOWS>goto start
    goto start [Enter=Y,Esc=N]?N
    C:\WINDOWS>
    C:\WINDOWS>
    
    C:\WINDOWS>_
    

    When Command is started with the /Z switch, the initial display on loading is:

    C:\WINDOWS>command /z
    
    Microsoft(R) Windows 95
       (C)Copyright Microsoft Corp 1981-1996.
    Return code (ERRORLEVEL):   0
    WARNING: Reloaded COMMAND.COM transient
    
    C:\WINDOWS>_
    

    Thereafter, the exit code (ERRORLEVEL number) returned by a program will be appended to any output from that program.
    For example, attempting to using XCOPY to transfer files from drive a: to c: when there is no disk in a: will result in an error and XCOPY will quit leaving an exit code of 4. This will display as:

    C:\WINDOWS>xcopy a:\*.* c:\
    Invalid path - a:\
    The device is not ready.
            0 File(s) copied
    Return code (ERRORLEVEL):   4
    
    C:\WINDOWS>_
    

  6. COMMAND contains an error handling routine that is used by a number of internal commands. If a command cannot be carried out because of a hardware/operator malfunction, the error message "Abort, Retry, Fail?" is displayed. For example, if the command "DIR a:" is entered and there is no disk in drive a:

    C:\> dir a:

    Not ready reading drive A
    Abort, Retry, Fail?_

    The only accepted responses to this are:

    A("Abort") The command is terminated and you are returned to the prompt.
    R("Retry") The command is run again - hopefully the problem has been corrected - eg a disk has been put into drive a:
    F("Fail") This accepts that the command could not be executed for whatever reason and you are returned to the prompt (though it sometimes takes 2 or 3 F's to get there).
    Ctrl-CThe command is cancelled and you are returned to the prompt.

    There is a difference between the ways A, F, and Ctrl-C are handled but, after much experimenting, I still cannot see any real pattern. In both cases, the command terminates and the user is returned to the prompt. This is true whether the command was issued from the command line or from within a batch file - in the latter case, the batch file also terminates. However, whilst the end result is very similar, it would seem that the F response causes a more orderly closure.

    For example: if dir a: is entered and there is no disk in drive a:, A will return you directly to the command prompt whereas F repeats the question. Pressing F a second time, gives the message that the disk in a: has no label and repeats the question. Pressing F a third time gives the message "Fail on interrupt 24", and then returns to the prompt:

    
    C:\WINDOWS> dir a:
    
    Not ready reading drive A
    Abort, Retry, Fail?
    Abort, Retry, Fail?f
    
    Not ready reading drive A
    Abort, Retry, Fail?f
    Volume in drive A has no label
    
    Not ready reading drive A
    Abort, Retry, Fail?f
    Fail on INT 24
    
    C:\WINDOWS>_ 

File Details

File NameDefault LocationDos Ver.Win Ver.SizeDateSource
Command.comc:\

c:\windows
7.0Win95 92 87011/07/95Precopy1.cab
7.1Win95 (OSR2.x) 93 81224/08/96Precopy1.cab
Win98 93 880?Precopy1.cab
Win98 SE 93 89023/04/99Precopy1.cab

Thanks to Lawrence R. Steeger for his advice on the "/Z" switch.
If you should have any comments or suggestions,
please contact: Bob Watson
.
This page last revised:
August 27, 2000.