Quick Tips

Showing posts with label batch. Show all posts
Showing posts with label batch. Show all posts

Run Multiple Dos Commands

|
Recently a colleague asked if I knew how to run multiple DOS commands from the command line. At first I said, no you cannot, only a batch file can do multiple commands. Then I remembered there may be a way and I did a Google search for run multiple commands in DOS and received 324,000 results. I clicked on the first result which is a blog, and got my answer. I also gathered additional information for older windows systems from Computerhope.com.

It so happens that you can separate multiple commands in DOS with an ampersand, "&". So you can do the following: "cd \ & dir" or any other number of multiple commands. Batch files are appropriate for anything complicated. But if all you wanted to do was something simple, just use the "&" and bunch your commands together. This will work in Microsoft Windows 2000 and Windows XP using cmd.exe. The same thing can be done on Microsoft Windows 95, Windows 98 and Windows ME using the pipe "|", such as cd\ | dir

The unix/linux equivalent would be a ";" to separate commands. Did you remember the use of the & in DOS? Do you still use DOS? If you do, what do you use it for?