如何在批处理文件(或从
Windows 命令行)以便使用 start
命令来
打开 URL 中包含 & 符号的网页?
双引号不适用于start
;这开始了一个新的
而是命令行窗口。
更新 1:Wael Dalloul 的解决方案有效。此外,如果 有 URL 编码的字符(例如,空格被编码为 %20) 在 URL 中并且它在批处理文件中 那么 '%' 必须是 编码为“%%”。示例中不是这种情况。
示例,来自命令行 (CMD.EXE
):
start http://www.google.com/search?client=opera&rls=en&q=escape+ampersand&sourceid=opera&ie=utf-8&oe=utf-8
将导致
http://www.google.com/search?client=opera
在默认浏览器中打开并在命令行窗口中出现这些错误:
'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.
'oe' is not recognized as an internal or external command,
operable program or batch file.
平台:Windows XP 64 位 SP2。
最佳答案
&
用于分隔命令。因此,您可以使用 ^
来转义 &
。
关于windows - 如何转义批处理文件中的符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1327431/