1.

Solve : "(" in a batch file!?

Answer»

What do brackets do in a batch file??Have you lost your Google finger :-?

Here is just one example (scroll down to the MDEL.BAT listing.)

Good luckThe parenthesis '(' and ')' serve different functions depending on where they are used. The most common example I can think of is to group COMMANDS or statements together. Take the following example:
Code: [Select]if ERRORLEVEL 1 (echo There was an error.
echo The ERRORLEVEL is %errorlevel%.
goto :EOF) else echo There was not an error.Typically, when a batch file processes an IF statement, and the IF statement is TRUE, then it will excute 1 command on the same LINE as the IF. Since we have 3 statements surrounded in the parenthesis, it will group them together and execute all 3.
Compare to:
Code: [Select]if ERRORLEVEL 1 echo There was an error.
echo The ERRORLEVEL is %errorlevel%.
goto :EOFIn the 2nd example, the LAST 2 lines of code get executed even when the IF statement is FALSE.

Does that explain it?
yes thnx
















































































































































































Discussion

No Comment Found