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

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

问题描述

我需要在运行时将 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天全站免登陆