Skip to main content
Everybody's taking a swing at "improving" this answer, but I didn't properly appreciate their improvements to my original answer, so I made my own update.
Source Link
djdanlib
  • 22.8k
  • 1
  • 23
  • 29

Like this on all Microsoft OSes since 2000, and still good today:

dir & echo foo

If you want the second command to execute only if the first exited successfully:

dir && echo foo

The single ampersand (&) syntax to execute multiple commands on one line goes back to Windows XP, Windows 2000, and some earlier NT versions. (4.0 at least on Win7, according to one commenter here.)

There are quite a few other points about this that you'll find scrolling down this page.

Historical data follows, for those who may find it educational.

Prior to that, the && syntax was only a feature of the shell replacement 4DOS before that feature was added to the Microsoft command interpreter.

In Windows 95, 98 and ME, you'd use the pipe character instead:

dir &| echo foo

In MS-DOS 5.0 and later, through some earlier Windows and NT versions of the command interpreter, the (undocumented) command separator was character 20 (Ctrl+T) which I'll represent with ^T here.

dir ^T echo foo

Like this, at least on Win7:

dir & echo foo

Like this on all Microsoft OSes since 2000, and still good today:

dir & echo foo

If you want the second command to execute only if the first exited successfully:

dir && echo foo

The single ampersand (&) syntax to execute multiple commands on one line goes back to Windows XP, Windows 2000, and some earlier NT versions. (4.0 at least, according to one commenter here.)

There are quite a few other points about this that you'll find scrolling down this page.

Historical data follows, for those who may find it educational.

Prior to that, the && syntax was only a feature of the shell replacement 4DOS before that feature was added to the Microsoft command interpreter.

In Windows 95, 98 and ME, you'd use the pipe character instead:

dir | echo foo

In MS-DOS 5.0 and later, through some earlier Windows and NT versions of the command interpreter, the (undocumented) command separator was character 20 (Ctrl+T) which I'll represent with ^T here.

dir ^T echo foo
Rollback to Revision 1
Source Link
djdanlib
  • 22.8k
  • 1
  • 23
  • 29

Like this, at least on Windows 7 (works on Windows 10 in 2017 too)Win7:

dir & echo foo

Like this, at least on Windows 7 (works on Windows 10 in 2017 too):

dir & echo foo

Like this, at least on Win7:

dir & echo foo
works on Windows still
Source Link
David
  • 2.7k
  • 2
  • 21
  • 32

Like this, at least on Windows 7 (works on Windows 10 in 2017 too):

dir & echo foo

(works on Windows 10) and in 2017

Like this, at least on Windows 7:

dir & echo foo

(works on Windows 10) and in 2017

Like this, at least on Windows 7 (works on Windows 10 in 2017 too):

dir & echo foo
Expanded.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
Loading
Source Link
djdanlib
  • 22.8k
  • 1
  • 23
  • 29
Loading