声明并使用DOS / Windows的批处理文件的变量(.BAT) [英] Declaring and using a variable in DOS/Windows batch file (.BAT)

查看:137
本文介绍了声明并使用DOS / Windows的批处理文件的变量(.BAT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想声明,并在我的批处理文件中使用的变量。它看起来应该很简单。

I'm trying to declare and use a variable in my batch file. It looks like it should be simple.

@ECHO OFF

SET location = "bob"
ECHO We're working with "%location%"

我得到的输出是:

The output I get is:

We're working with ""

这是怎么回事?为什么我的变量没有被回显的?

What's going on here? Why is my variable not being echo'd?

推荐答案

在空间中的 = 是国际preTED作为名称的一部分,并且空间之后(以及引号)是PTED作为值的零件间$ p $。所以,你所创建的变量可以用%位置%引用。如果这不是你想要的东西,删除的定义额外的空间(S)。

The space before the = is interpreted as part of the name, and the space after it (as well as the quotation marks) are interpreted as part of the value. So the variable you’ve created can be referenced with %location %. If that’s not what you want, remove the extra space(s) in the definition.

这篇关于声明并使用DOS / Windows的批处理文件的变量(.BAT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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