我正在批量制作一个游戏,因为它很简单,我试图写一个其他的状态,但我已经知道我只能在每个类中使用其他一个,所以只有一个输入才能工作,但是我需要使用multipul。
cls
color 02
ECHO Welcome to your hacking console, you can type main to get back to the main menu
set /p input=Command:
if %input%==main (
goto main
) else (
goto error
)
if %input%==tracert (
goto tracert
) else (
goto error
)
if %input%==IPlookup (
goto IPlookup
) else (
goto error
)发布于 2014-04-09 02:43:00
你不需要别人-你只是想做一些事情,如果没有其他的如果语句做某事:
cls
color 02
ECHO Welcome to your hacking console, you can type main to get back to the main menu
set /p input=Command:
if %input%==main goto main
if %input%==tracert goto tracert
if %input%==IPlookup goto IPlookup
goto error发布于 2014-08-18 05:05:46
每当在if语句之后只有一个命令时,就可以在之后发布它。我知道曾傑瑞有一个很好的答案,但我只是想增加更多细节。
如果我需要执行多个任务,(将非常有用。下面是一个例子:
if %x%==1 (
:: do some stuff
:: do more stuff
:: do even more stuff
)但是如果我只需要do some stuff,我就把它放在一行中。
if %x%==1 :: do some stuff因为在你的脚本中,你跳到另一个标签,一旦你点击那个if语句,你就离开了脚本的那一部分。我的意思是:
if %x%==1 goto label_01
echo this won't get displayed unless %x% isn't equal to "1"
:label_01
echo anything after the "if" line wont get displayed, since we are here.而且,由于批处理脚本是由cmd.exe从左到右、从上到下读取的,所以我们可以对这些if语句进行叠加。
if %x%==1 goto label_01
if %x%==2 goto label_02
if %x%==3 goto label_03
:: we now know that %x% is not equal to 1, 2, or three. so now we can take advantage of that and post some script.
:: do some stuff由于您的脚本似乎是基于菜单系统的,所以我建议对它做一些修改:
cls
color 02
ECHO Welcome to your hacking console!
echo.
echo Press 1 to go back to the main menu
echo Press 2 to Tracerout
echo Press 3 to Lookup IP address
choice /c 123 >nul
set input=%errorlevel%
if %input%==1 goto main
if %input%==2 goto tracert
if %input%==3 goto IPlookup这种方法省去了我们对goto error的需求。这也节省了时间,因为现在你只需要输入一个数字,而不是输入一个完整的单词。如果键入不支持的数字,则不会发生任何情况。
当然,如果您在XP上运行,此方法将无法工作。
顺便说一下黑客机器?我记得编写了几个这样的脚本。除了我的有DOS攻击和浏览器密码提取器的选项:)
https://stackoverflow.com/questions/22951654
复制相似问题