简体   繁体   English

Windows Cmd Line For Loops

[英]Windows Cmd Line For Loops

I wish to get the value of the input after the -c switch that is input by the user through the batch file in Windows NT.我希望得到用户通过Windows NT中的批处理文件输入的-c开关后输入的值。

Eg:例如:

run.bat -c node1
;Expected value = "node1"

run.bat -b abc -c node1
;Expected value = "node1"

run.bat -b abc -c node1 -d testing
;Expected value = "node1"

Anyone can help?任何人都可以帮忙吗?

@REM Put the contents in a batch file
@IF "" == "%1" @GOTO DONE

:ARGS
@IF "-c" == "%1" @GOTO PRINT
@SHIFT
@IF "" == "%1" @GOTO DONE
@GOTO ARGS
@GOTO DONE

:PRINT
@SHIFT
@IF NOT "" == "%1" @ECHO %1
@GOTO ARGS

:DONE
@REM End of file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM