How can I pass arguments to a batch file?

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

    In batch file

    set argument1=%1
    set argument2=%2
    echo %argument1%
    echo %argument2%
    

    %1 and %2 return the first and second argument values respectively.

    And in command line, pass the argument

    Directory> batchFileName admin P@55w0rd 
    

    Output will be

    admin
    P@55w0rd
    

提交回复
热议问题