在Windows批处理文件中使用“^”转义行尾字符不会';你不能在某些线路上工作吗?

在Windows批处理文件中使用“^”转义行尾字符不会';你不能在某些线路上工作吗?,windows,batch-file,cmd,command-line,Windows,Batch File,Cmd,Command Line,我有一个批处理文件,我把它放在一起,以便在一次单击中自动启动一个程序和几个相关程序。与问题有关的部分: echo使用Elite选项卡集启动FireFox。。。 cd“C:\Program Files\Mozilla Firefox\” 启动firefox.exe^ https://inara.cz/cmdr/276665/ https://coriolis.io/ ^ https://www.edsm.net/ ^ http://www.elitedangeroustrading.com/tra

我有一个批处理文件,我把它放在一起,以便在一次单击中自动启动一个程序和几个相关程序。与问题有关的部分:

echo使用Elite选项卡集启动FireFox。。。
cd“C:\Program Files\Mozilla Firefox\”
启动firefox.exe^
https://inara.cz/cmdr/276665/ https://coriolis.io/ ^
https://www.edsm.net/ ^
http://www.elitedangeroustrading.com/trade-assistant.aspx ^
https://www.edtutorials.com/ ^
"file:///C:/Program 文件(x86)/VoiceAttack/Sounds/HCS工具/链接和文档/控制包/Singularity(Elite)/Singularity reference guide.pdf“file:///C:/Program 文件(x86)/VoiceAttack/Sounds/HCS工具/链接和文档/Companion Pack/Ships assistant Ad Astra/Ad Astra参考指南。pdf“”file:///C:/Program 文件(x86)/VoiceAttack/Sounds/HCS Tools/.Voice命令列表/Elite危险语音命令/Singularity ship命令.html“”file:///C:/Users/Guillermo/Downloads/ebonym-t16000mfcs.jpg“
回声开始发现。。。
如您所见,为了可读性,我使用了
^
字符将
启动firefox
命令分成多行。如图所示,此文件有效。但是,请注意倒数第二行,它以“
file://
”开头。该行上有多个参数。我想做的是:

echo使用Elite选项卡集启动FireFox。。。
cd“C:\Program Files\Mozilla Firefox\”
启动firefox.exe^
https://inara.cz/cmdr/276665/ https://coriolis.io/ ^
https://www.edsm.net/ ^
http://www.elitedangeroustrading.com/trade-assistant.aspx ^
https://www.edtutorials.com/ ^
"file:///C:/Program 文件(x86)/语音攻击/声音/HCS工具/链接和文档/控制包/奇点(Elite)/奇点参考指南.pdf“^
"file:///C:/Program 文件(x86)/VoiceAttack/Sounds/HCS工具/链接和文档/配套软件包/Ships assistant Ad Astra/Ad Astra参考指南.pdf“^
"file:///C:/Program 文件(x86)/VoiceAttack/Sounds/HCS Tools/.Voice命令列表/Elite危险语音命令/Singularity ship Commands.html”^
"file:///C:/Users/Guillermo/Downloads/ebonym-t16000mfcs.jpg“
回声开始发现。。。
当我这样做时,我得到以下输出:

C:\ProgramFiles(x86)\VoiceAttack>echo启动FireFox,使用Elite选项卡集。。。
正在使用Elite选项卡集启动FireFox。。。
C:\ProgramFiles(x86)\VoiceAttack>cd“C:\ProgramFiles\Mozilla Firefox\”
C:\Program Files\Mozilla Firefox>start Firefox.exehttps://inara.cz/cmdr/276665/ >https://coriolis.io/ https://www.edsm.net/ http://www.elitedangeroustrading.com/trade-assistant.aspx https://www.edtutorials.com/ "file:///C:/Program 文件(x86)/语音攻击/声音/HCS工具/链接和文档/控制包/奇点(Elite)/奇点参考指南.pdf“^
C:\Program Files\Mozilla Firefox>“file:///C:/Program 文件(x86)/VoiceAttack/Sounds/HCS工具/链接和文档/Companion Pack/Ships assistant Ad Astra/Ad Astra参考指南。pdf“”file:///C:/Program 文件(x86)/VoiceAttack/Sounds/HCS Tools/.Voice命令列表/Elite危险语音命令/Singularity ship Commands.html”^
文件名、目录名或卷标语法不正确。
C:\Program Files\Mozilla Firefox>“file:///C:/Users/Guillermo/Downloads/ebonym-t16000mfcs.jpg“
文件名、目录名或卷标语法不正确。
C:\Program Files\Mozilla Firefox>echo启动EDDiscovery。。。
正在启动EDDiscovery。。。

我不明白为什么我能把前4个参数分开,但不能把以
文件://
。我是否遗漏了
^
的某些细微之处或使用不当?这种清理有没有不同的方法?我承认这纯粹是一个可读性问题,但无法解释这种行为令人烦恼。

问题是以双引号开头的行,因为行尾的插入符号会转义行尾和下一行的第一个字符。
这将导致转义第一个引号,而行尾的“结束”引号将被解释为“开始”引号

这可以通过简单地在每行前面加一个空格来解决

start firefox.exe ^
https://www.edsm.net/ ^
https://www.edtutorials.com/ ^
 "file:///C:/Program Files/guide.pdf" ^
 "file:///C:/Program Files/blapdf" ^
...
对于这个问题还有第二个更模糊的解决方案,在插入符号前面添加重定向。
使用这种方法,下一行的第一个字符按预期工作(不会转义)

启动firefox.exe^

https://www.edsm.net/ 你有没有想过把所有的地址都加倍引用,而不是那些你知道有空格的地址?我会说这是一个很好的实践。也许相关:。
start firefox.exe ^
https://www.edsm.net/ <nul ^
https://www.edtutorials.com/ <nul ^
"file:///C:/Program Files/guide.pdf" <nul ^
"file:///C:/Program Files/blapdf" <nul ^
...