相关疑难解决方法(0)

如何在批处理文件中转义&符号?

如何在批处理文件(或从Windows命令行)中转义&符号,以便使用该start命令在URL中打开带有&符号的网页?

双引号不适用start; 这会启动一个新的命令行窗口.

更新1:Wael Dalloul的解决方案有效.此外,如果URL中存在URL编码字符(例如,空格编码为%20)并且它位于批处理文件中,则'%'必须编码为'%%'.在示例中不是这种情况.

例如,从命令行(CMD.EXE):

start http://www.google.com/search?client=opera&rls=en&q=escape+ampersand&sourceid=opera&ie=utf-8&oe=utf-8
Run Code Online (Sandbox Code Playgroud)

会导致

http://www.google.com/search?client=opera 
Run Code Online (Sandbox Code Playgroud)

在默认浏览器中打开并在命令行窗口中显示以下错误:

'rls' is not recognized as an internal or external command,
operable program or batch file.
'q' is not recognized as an internal or external command,
operable program or batch file.
'sourceid' is not recognized as an internal or external command,
operable program or batch file.
'ie' is not recognized as an internal or external command,
operable program or batch file. …
Run Code Online (Sandbox Code Playgroud)

windows escaping batch-file

135
推荐指数
5
解决办法
10万
查看次数

标签 统计

batch-file ×1

escaping ×1

windows ×1