如何在 if/else 块中逐字回显右括号?

如何在 if/else 块中逐字回显右括号?

问题描述:

这是我的代码:

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!
)

它崩溃了,因为它说:

echo 1)!%currentuser%program1!

右括号用作 if 语句的结尾,但我希望它在字面上得到回应.
我认为解释器会看到这一点:

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?

尝试在要回显的括号中添加脱字符 (^) 符号前缀.

Try adding a caret (^) symbol prefix to the bracket you want to echo.

http://www.robvanderwoude.com/escapechars.php