编辑:我解决了这个问题。我的输入变量和“如果”变量是不同的,我在更改后忘记更改其中的一个变量。
所以我的代码遇到了问题。
错误;
"goto installupdate" was unexpected at this time所有的一切都到了
if %updatech%==Y goto iu
if %updatech%==y goto iu
if %updatech%==N goto noupdate
if %updatech%==n goto noupdate我不知道我做错了什么。有人知道我的代码出了什么问题吗?
代码:
REM检查安装程序的更新
:updatecheck
bitsadmin.exe /transfer "updatecheck" "http://serverse.playat.ch/overtone/update.txt" "%temp%\overtoneupdate.txt"
set /p versioncompare=<"%temp%\overtoneupdate.txt"
del "%temp%\overtoneupdate.txt"
cls
if %currentbuild% == %versioncompare% goto noupdate
set /p updateyn=New version found! Would you like to update? [Y/N]:
if %updatech%==Y goto iu
if %updatech%==y goto iu
if %updatech%==N goto noupdate
if %updatech%==n goto noupdate
goto updatecheck
:iu
bitsadmin.exe /transfer "update" "http://serverse.playat.ch/overtone/%versioncompare%update.bat" "%cd%\update.bat"
echo %versioncompare%>upvers.txt
update.bat
exit
:noupdate
cls
goto install发布于 2016-05-04 13:11:59
在下面的代码行中,您将设置一个名为updateyn的变量,但要检查一个名为updatech的变量。
set /p updateyn=New version found! Would you like to update? [Y/N]:
if %updatech%==Y goto iu这始终是空的,所以它失败了,因为它归结为
if ==Y goto iu这是无效的语法。
除了修复变量名之外,还应该考虑用户只按enter (这将导致同样的问题)的情况。
您可以通过在变量周围放置一个已知的字符串来解决这个问题。
if x%updateyn%x==xYx goto iu例如。
https://stackoverflow.com/questions/37028711
复制相似问题