1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: multiple commands in CMD?

Discussion in 'DOS/Other' started by obidon, Mar 25, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. obidon

    obidon Banned Thread Starter

    Joined:
    Aug 12, 2007
    Messages:
    184
    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.
     
  2. devil_himself

    devil_himself

    Joined:
    Apr 7, 2007
    Messages:
    4,910
    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
    
     
  3. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
     
  4. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,731
    Do you need to use the output of command one for Command 2? If so you can just pipe it to the next command.
     
  5. devil_himself

    devil_himself

    Joined:
    Apr 7, 2007
    Messages:
    4,910
    Ahh... Thank You TheOutcaste
     
  6. devil_himself

    devil_himself

    Joined:
    Apr 7, 2007
    Messages:
    4,910
    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.
     
  7. obidon

    obidon Banned Thread Starter

    Joined:
    Aug 12, 2007
    Messages:
    184
    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.
     
  8. devil_himself

    devil_himself

    Joined:
    Apr 7, 2007
    Messages:
    4,910
    Glad We Could Help

    :)
     
  9. Sponsor

As Seen On
As Seen On...

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.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/697113