如何批量使用if语句后转到goto

时间:2015-06-26 18:28:56

标签: batch-file if-statement goto

我确定这个问题已被提出,或者很明显,但我似乎无法找到答案!我正在批量制作一种闲置的点击游戏,并且我坚持要去升级页面。我的想法是,我希望玩家按Enter键赚钱,然后输入“upg”进入升级页面。我收到一个错误,指出此时无法识别goto命令。然后脚本关闭。这就是我所拥有的:

@echo off
title HackerClicker 1.2.1
color 0a
:start
set /a mon = 0 
echo HkrAssociation Hack protocal v. 1.2.1
echo 2015 HkrAssociation. All rights reserved.
echo.
echo press and hold enter in hack routine to auto-hack and gain money
echo.
set /p= "PRESS ANY KEY TO START ROUTINE"
goto routine

:routine
cls
echo Hack Routine v. 1.2.1
echo. 
echo Balance: $%mon%
echo.
echo Type "upg" to go to upgrades
echo.
set /p cmd= "C:\users\h@ck3r\hack_routine>"
set /a mon = %mon% + 1
if %cmd%= upg GOTO upgrades
goto routine

:upgrades
echo more here later
set /p=

谢谢!

1 个答案:

答案 0 :(得分:0)

批量使用一个等号用于分配,两个等号用于比较。因此,您需要使用两个相等的符号来查看%cmd%是否为“upg”:

if %cmd%==upg GOTO upgrades