How can I pass arguments to a batch file?

后端 未结 18 2378
陌清茗
陌清茗 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:14

    FOR %%A IN (%*) DO (
        REM Now your batch file handles %%A instead of %1
        REM No need to use SHIFT anymore.
        ECHO %%A
    )
    

    This loops over the batch parameters (%*) either they are quoted or not, then echos each parameter.

提交回复
热议问题