gpt4 book ai didi

windows - 如何转义批处理文件中的符号?

转载 作者:可可西里 更新时间:2023-11-01 11:52:37 29 4
gpt4 key购买 nike

如何在批处理文件(或从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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com