Reputation:
So here is my code:
if "!%currentuser%program1!" == "None" (
REM EASTER EGG this is here because i am not confident with using the not switch
)
ELSE
(
echo 1)!%currentuser%program1!
)
And it crashes because where it says:
echo 1)!%currentuser%program1!
The closing parenthesis is used as an end to the if
statement but I want it to be literally echoed.
I think the interpreter sees this:
if "!%currentuser%program1!" == "None"
(
REM EASTER EGG this is here because i am not confident with using the not switch
)
ELSE
(
echo 1
)!%currentuser%program1!
)
And the last 2 lines are obviously an error.
How can I make it actually echo the closing parenthesis?
Upvotes: 1
Views: 65
Reputation: 80033
IF
true-condition targetif
else
keyword must be on the same physical lineelse
keyword, a separator and the opening parenthesis of the "else" block must be on the same physical lineie
if condition (
something
) else (
someotherthing
)
Also, you must escape the literal )
otherwise batch interprets it as an end-of-block
Upvotes: 1
Reputation: 38333
Try adding a caret (^) symbol prefix to the bracket you want to echo.
http://www.robvanderwoude.com/escapechars.php
Upvotes: 2