Quick Tips

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?

4 comments:

Anonymous said...

I did not know you could run two DOS commands at the same time, that's a great tip. I do use DOS, but mainly for troubleshooting internet connectivity. I try releasing the ip, checking the ip, pinging yahoo, little stuff like that.

FrugalNYC said...

Hi Anonymous. I'm glad you found this useful. It comes in handy when you need to do link one or two items together quickly in a command prompt. Thanks for visiting and for your comment.

Anonymous said...

Hi, and thanks for the tip. I use DOS quite a bit actually. Like for instance I use the 'xcopy' command with modifiers in a .bat file and then 'chron' it with Windows Task Scheduler for twice an hour backups of modified files from my work folder to a remote machine.

There are lots of other uses. Like simple installers, without having to purchase of license Installshield and similar software, etc.

Chino

FrugalNYC said...

Thanks for dropping by! Scripting is definitely a great way to do things. I use it quite often to just clean out directories and such, much easier than clicking, clicking, clicking.

Post a Comment