Hello!
Could you please tell me how to call several commands in one line?
For example, I want to have a single line which will act as the sequence:
echo Bla-bla-bla! Let us call dir?
dir
echo More-bla-bla-bla!
I have no idea of implementing this. Is it possible?
Thanks a lot! It's a very nice and useful site.
Multiple commands per line
Moderator: DosItHelp
EDIT: I can't get example 2 working, but maybe someone know how it works :p
in batch files and in CMD you can use:
This will operate each command at nearly same time and output will be showed line by line![Smile :-)](./images/smilies/icon_smile.gif)
in CMD you can also use (If you are lucky it also works in batch files):
This will do the same as "(" ")" but will show output on ONE line instead![Very Happy :-D](./images/smilies/icon_biggrin.gif)
example 1:
example 2:
Have fun!
Best regards
Odder
in batch files and in CMD you can use:
Code: Select all
(
<command1>
<command2>
<command3>
<etc.>
)
This will operate each command at nearly same time and output will be showed line by line
![Smile :-)](./images/smilies/icon_smile.gif)
in CMD you can also use (If you are lucky it also works in batch files):
Code: Select all
^
<command1>^
<command2>^
<command3>^
<etc>^
<last command>
This will do the same as "(" ")" but will show output on ONE line instead
![Very Happy :-D](./images/smilies/icon_biggrin.gif)
example 1:
Code: Select all
(
echo blah blah blah... let's jump to root
cd ..
echo blah blah blah...
)
example 2:
Code: Select all
^
echo blah blah blah... let's jump to root^
cd ..^
echo blah blah blah...
Have fun!
Best regards
Odder
gallennc wrote:If you want to execute this on one line:
echo Bla-bla-bla! Let us call dir?
dir
echo More-bla-bla-bla!
shouldn't it be as simple as:
echo Bla-bla-bla! Let us call dir? & dir & echo More-bla-bla-bla!
works for me.
ohh, that way
![Wink ;-)](./images/smilies/icon_wink.gif)
I have read you should use "&" twice, as:
Code: Select all
echo Bla-bla-bla! Let us call dir? && dir && echo More-bla-bla-bla!
But it might work both ways
![Shocked :shock:](./images/smilies/icon_eek.gif)
re
you can use single & symbols in if's eg:
Code: Select all
if '%var%'=='this' echo lalala & echo Still in the if !!! & echo omg still in there, i think? i think there may be a limit of and symbols but yea & pause & exit
-
- Posts: 36
- Joined: 17 Jul 2008 07:37
See http://technet.microsoft.com/en-us/libr ... 37438.aspx
&& means 'do the next one if the last one completed OK'
&& means 'do the next one if the last one completed OK'