如何将参数传递给批处理文件? [英] How can I pass arguments to a batch file?

查看:92
本文介绍了如何将参数传递给批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在运行时将ID和密码传递给批处理文件,而不是将其硬编码为文件.

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.

这是命令行的样子:

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

推荐答案

这是我的操作方式:

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

这是命令的样子:

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

%1适用于第一个参数,%2(这是棘手的部分)适用于第二个参数.您最多可以通过这种方式传递9个参数.

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.

这篇关于如何将参数传递给批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆