How can I pass arguments to a batch file?

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

    If you want to intelligently handle missing parameters you can do something like:

    IF %1.==. GOTO No1
    IF %2.==. GOTO No2
    ... do stuff...
    GOTO End1
    
    :No1
      ECHO No param 1
    GOTO End1
    :No2
      ECHO No param 2
    GOTO End1
    
    :End1
    

提交回复
热议问题