我如何获得一个批处理脚本两个可变从一行 [英] How do I get two variable from one line in a batch script

查看:120
本文介绍了我如何获得一个批处理脚本两个可变从一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何让一个批处理文件需要一条线,并设置两个不同的值是备份的文件。

I am trying to work out how to make a batch file take one line and set two separate values it is to backup a file.

例如备份 C:\\ PROGRAMFILES D:\\

我怎样才能得到这两个值与用户输入的一行?

How can I get both of those values from one line of user input?

推荐答案

批处理文件可以直接通过9%处理参数%0。

Batch files can directly handle parameters %0 through %9.

%0 is the program name as it was called,
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9.

所以,如果你执行的命令是这样的:

So, if you executed the command like this:

backup c:\Programs d:\

在批处理文件,你可以参考这些值:

Within the batch file you could refer to these values:


  • 0% = 备份

%1 = C:\\程序

%2 = D:\\

请记住,如果你在文件名没有空间与周围的引号整个路径,它不是去上班你想要的方式。

Keep in mind that if you have spaces in the filenames without surrounding the entire path with quotes, it's not going to work the way you're wanting.

这篇关于我如何获得一个批处理脚本两个可变从一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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