如何识别批处理文件中的用户输入帮助(/?) [英] How to identify user input help (/?) in batch file
本文介绍了如何识别批处理文件中的用户输入帮助(/?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通常在大多数批处理命令中,它使用 /?
来获取特定命令的描述或hel。
所以有一个方法来识别用户是通过输入 /?
作为参数( mybatchfilename /?
)
我试过 IF%1 == /? goto帮助
。
任何帮助?
为了解决这个问题,你可以在你的if参数的引号()。
<$> p $ p>
如果%1==/?goto帮助
@echo off
pre>
if %1==/?goto help
:main
echo在这里没有帮助
echo只是做东西
exit / b 1
:help
echo这个文件正在帮助你...
timeout 1> nul
echo只是开玩笑
退出/ b 0
Usually in most of the batch command, it uses
/?
to get the description or hel of the particular command. So is there a way to identify user is asking for the help by entering/?
as argument (mybatchfilename /?
)I have tried
IF %1==/? goto Help
. but seems?
has special meaning in batch command.Any help?
解决方案To fix this problem, you can put quotes (") around your if parameters. Like so:
if "%1" == "/?" goto Help
This works and it fixes your problem. A working example? Here you go:
@echo off if "%1" == "/?" goto help :main echo No help here. echo Just doing stuff exit /b 1 :help echo The file is helping you... timeout 1 >nul echo Just kidding. exit /b 0
这篇关于如何识别批处理文件中的用户输入帮助(/?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文