From this website, the OP has noticed a problem.


Cause

Consider the following code snippet.

if 1==1 (
    set /a result = 2*(3+4)
)

At your first glance, you may think CMD.exe would process it like so:

  • The condition is true, execute code block
  • Set variable result's value to 14
  • Continue

However, CMD.exe process like so:

  • The condition is true, execute code block
  • Calculate 2*(3+4, the ) after 4 is processed at the end of if code block
  • A random ) has appeared!

The second step would return Unbalanced parentheses error.


Solution

According to a German CMD.exe's set /?, we would need to quote arithmetic operations. Here's an example.

PreviousResult
set /a result=2+5*4set /a result="2+5*4"

By the way, according to an English CMD.exe set /?, quotes are required if logical or modulus operators are present in the expression(although this is not a must-do step).