Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

Solved: multiple commands in CMD?


(!)

obidon's Avatar
obidon obidon is offline
Account Disabled with 184 posts.
THREAD STARTER
 
Join Date: Aug 2007
Experience: Intermediate
25-Mar-2008, 09:51 PM #1
Question Solved: multiple commands in CMD?
Does anyone know if it's possible to run multiple commands in a single CMD command? I mean like be able to run more than one command without the need to hit Enter and then all the commands specified will be run just by typing the long command. I think this would be useful say if you wanted to complete a bunch of commands but didn't want to have to wait till the previous commands completed before executing the next ones. I know that you can use a batch file to do this, but I was just wondering if there was a way to do it straight from CMD. Thanks for replies.
devil_himself's Avatar
Member with 4,910 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
26-Mar-2008, 12:22 AM #2
This Will Help

Code:
 
& 
 command1 & command2 
 Execute Command1 and then execute Command2
 
&& 
 command1 && command2
 Runs the command2 only when command1 doesn't Complete successfully
 
|| 
 command1 || command2
 Runs the second command if the first command had an error
 
() 
 (command1 || command2) || (command3 & command4) 
 Defines the order in which commands are to be executed
TheOutcaste's Avatar
Computer Specs
Member with 9,028 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
26-Mar-2008, 10:43 PM #3
Quote:
Originally Posted by devil_himself View Post
This Will Help

[code]

&&
command1 && command2
Runs the command2 only when command1 doesn't Complete successfully
Actually this should be "command2 runs only if command1 DOES complete successfully
Squashman's Avatar
Trusted Advisor with 19,645 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
26-Mar-2008, 11:10 PM #4
Do you need to use the output of command one for Command 2? If so you can just pipe it to the next command.
devil_himself's Avatar
Member with 4,910 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
26-Mar-2008, 11:12 PM #5
Ahh... Thank You TheOutcaste
devil_himself's Avatar
Member with 4,910 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
26-Mar-2008, 11:15 PM #6
More Info .. Copied From "ntcmds.chm" Present In "%SystemRoot%\Help"

>
Writes the command output to a file or a device, such as a printer, instead of the Command Prompt window.

<
Reads the command input from a file, instead of reading input from the keyboard.

>>
Appends the command output to the end of a file without deleting the information that is already in the file.

>&
Writes the output from one handle to the input of another handle.

<&
Reads the input from one handle and writes it to the output of another handle.

|
Reads the output from one command and writes it to the input of another command. Also known as a pipe.
obidon's Avatar
obidon obidon is offline
Account Disabled with 184 posts.
THREAD STARTER
 
Join Date: Aug 2007
Experience: Intermediate
28-Mar-2008, 04:49 PM #7
Sick, thanks for that info devil_himself, it was just what I was looking for. And thanks for all the other replies from everyone else.
devil_himself's Avatar
Member with 4,910 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
28-Mar-2008, 09:46 PM #8
Glad We Could Help

As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑