开发者

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.

E.g:

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

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

run.bat -开发者_Python百科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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜