How can I pass arguments to a batch file?

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

    Here's how I did it:

    @fake-command /u %1 /p %2
    

    Here's what the command looks like:

    test.cmd admin P@55w0rd > test-log.txt
    

    The %1 applies to the first parameter the %2 (and here's the tricky part) applies to the second. You can have up to 9 parameters passed in this way.

提交回复
热议问题