如何串联包含空格的局部变量 [英] How to concatenate local variables which contain spaces

查看:58
本文介绍了如何串联包含空格的局部变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过此链接尝试Hertzel Guinness'方法.也许我误会了它,但似乎无法使它起作用. Windows7 版本6.1.7601 .

I am trying Hertzel Guinness' method from this link. Perhaps I am misunderstanding it but I cannot seem to get it to work. Windows7 Version 6.1.7601.

我的代码是:

set pathA ="C:\ProgramData\Microsoft\Windows\Start Menu\Programs"
set pathB ="Libraries\Documents"
set pathA=%pathA:~1,-1%%pathB:~1,-1%
%pathA%

输出显示:

.. Desktop \ BatchFiles>〜1,-1%pathB:〜1,-1'〜1'无法识别为内部或外部命令,可操作程序或批处理文件.

..Desktop\BatchFiles>~1,-1%pathB:~1,-1 '~1' is not recognized as an internal or external command, operable program or batch file.

推荐答案

不包含某些内容比随后添加并删除它要容易得多.

It's much easier to not include something than to do so and subsequently remove it.

@Echo Off
Set "pathA=C:\ProgramData\Microsoft\Windows\Start Menu\Programs"
Set "pathB=Libraries\Documents"
Set "pathA=%pathA%%pathB%"
Echo "%pathA%"
Pause

这篇关于如何串联包含空格的局部变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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