开发者

Windows Cmd Line For Loops

开发者 https://www.devze.com 2023-03-11 18:32 出处:网络
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.

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

精彩评论

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