IF DEFINED for more than one variables?
Currently I am doing this in my batch file and it works fine
IF DEFINED var1 (do something) ELSE (do something else)
Now I want to check more than one variables are defined or not with an AND
operator between them. How can I achieve that?
for example something like
IF DEFINED(var1) && DEFINED(var2) (do something) ELSE (do something else)
Update: I know I can do nesting but I am looking for a c开发者_运维百科lean approach...
You'll have to perform two IFs consequently, like you can see in @Vinnyq12's answer. The ELSE part can be related to only one IF, so you'll have to repeat it for each IF. If you wish to avoid repeating the same operation, you can do something like this:
IF DEFINED var1 IF DEFINED var2 GOTO iftrue
do something else
GOTO continue
:iftrue
do something
:continue
…
Nest your second if inside the (do something)
IF DEFINED var1 (**IF DEFINED var2 (do something) ELSE (do something else)**) ELSE (do something else)
精彩评论