Microsoft KB Archive/279253

= Multiple Commands on a Single Line May Not Run When You Use the && Command Separator =

Article ID: 279253

Article Last Modified on 3/2/2007

-

APPLIES TO


 * Microsoft Windows NT Server 4.0, Terminal Server Edition
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition
 * Microsoft Windows 2000 Datacenter Server
 * Microsoft Windows NT Workstation 4.0 Developer Edition
 * Microsoft Windows NT Server 4.0 Standard Edition
 * Microsoft Windows NT Server 4.0 Enterprise Edition

-



This article was previously published under Q279253





SYMPTOMS
The double ampersand (&&) command separator may not run the commands to the right of && command.

For example, when you run the following command, the pause command does not run when a floppy disk is not in drive A, and you receive a &quot;The device is not ready&quot; message:

dir a: && pause



CAUSE
This behavior occurs because the && command separator performs error checking. If the command to the left of the && command does not return the expected results, the commands to the right of the && command do not run.



RESOLUTION
To resolve this issue, use the single & command separator. When you use a single & command, error checking is not performed and all commands run.

The following sample command displays a list of files in the current folder, and then runs the pause command even if the dir a: command does not work:

dir a: & pause

The following samples provide more examples of the && command separator. Note that in these examples,  ,  , and   represent commands.

Example 1

 &&   &&  

If command   does not run, then commands   and command   do not run. If command   does not run, then command   does not run.

Example 2

 &   &  

In this example, commands  ,  , and   always run.



STATUS
This behavior is by design.



MORE INFORMATION
To view the online documentation for the && command separator or for other MS-DOS commands, type the following command at a command prompt:

cmd /?

Additional query words: ampersand

Keywords: kbenv kbprb KB279253

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.