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

问题描述

我正在尝试通过此链接尝试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%

输出显示:

推荐答案

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

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

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

10-10 13:18