call commands using in a single line

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
KSKwin123
Posts: 4
Joined: 21 Dec 2021 23:12

call commands using in a single line

#1 Post by KSKwin123 » 06 Sep 2022 00:35

how to call 2 subroutine in a same command line in an batch file

eg
call :subroutine1 && :subroutine2

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Re: call commands using in a single line

#2 Post by miskox » 06 Sep 2022 01:57

Maybe

Code: Select all

call :sub1&call :sub2
?

or maybe

Code: Select all

(call :sub1)&(call :sub2)
Saso

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: call commands using in a single line

#3 Post by aGerman » 06 Sep 2022 02:07

Yeah, the && is like a conditional command concatenation. Only if :subroutine1 returns errorlevel 0 :subroutine2 will be called. So a single & might be the better choice.

However, having both call commands in one line does not mean that the subroutines are running asynchronously (in parallel). They are still executed one after the other.

Steffen

KSKwin123
Posts: 4
Joined: 21 Dec 2021 23:12

Re: call commands using in a single line

#4 Post by KSKwin123 » 06 Sep 2022 09:10

HI,

Single & works well. Thanks for your help.

Post Reply