(这时是意外的批处理
问题描述:
批量运行时,出现(这时出乎意料"错误.为什么?我在变量和变量等于两边都加了引号.y后面有一个空格,然后是括号./p>
When running this in batch, I get a "( was unexpected at this time" error. Why? I have quotes surrounding both the variable and what the variable is equal to. There's a space after y, and then parentheses.
echo Would you like to update and restore to the latest OS? (-l -e) (Y/N)
set /p latestOS= ""
if "%latestOS%"=="y" (
echo Restoring...make sure your device is plugged in!
\idevicerestore\idevicerestore -l -e
echo Done.
timeout /t 2 /nobreak > NUL
) else (
echo Okay. Where is the IPSW located? EX: C:\memez.ipsw
set /p IPSWlocid= ""
echo Alright. Is it a custom IPSW? Note that the device must be vulnerable to limera1n. (-c) (Y/N)
set /p IPSWiscustomid= ""
rem more stuff soon
)
:menu
在if LatestOS行中失败.
It fails at the if latestOS line.
答
当您有一个代码块(括号内的代码)时,无论在何处,批处理都将第一个未转义的)视为该块的结尾.在代码块中找到它.
When you have a code block (that's code inside of parentheses), batch considers the first unescaped ) to be the end of that block, regardless of where in the code block it is located.
else块中的第二个echo破坏了代码.要解决此问题,请使用^转义两个).
The second echo inside of your else block is breaking your code. To fix it, use ^ to escape both of the )s.
echo Alright. Is it a custom IPSW? Note that the device must be vulnerable to limera1n. (-c^) (Y/N^)