How can I pass arguments to a batch file?

后端 未结 18 2141
陌清茗
陌清茗 2020-11-22 02:53

I need to pass an ID and a password to a batch file at the time of running rather than hardcoding them into the file.

Here\'s what the command line looks like:

18条回答
  •  无人及你
    2020-11-22 03:12

    @ECHO OFF
    :Loop
    IF "%1"=="" GOTO Continue
    SHIFT
    GOTO Loop
    :Continue
    

    Note: IF "%1"=="" will cause problems if %1 is enclosed in quotes itself.

    In that case, use IF [%1]==[] or, in NT 4 (SP6) and later only, IF "%~1"=="" instead.

提交回复
热议问题