如何串联包含空格的局部变量
问题描述:
我正在尝试通过此链接尝试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