我如何逃脱在批处理文件&符号? [英] How do I escape ampersands in batch files?

查看:195
本文介绍了我如何逃脱在批处理文件&符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何逃脱一个批处理文件符号(或从
Windows命令行),以使用启动命令
打开网页&符号用在URL?

How do I escape ampersands in a batch file (or from the Windows command line) in order to use the start command to open web pages with ampersands in the URL?

双引号不会与工作启动;这将启动一个新的
命令行窗口,而不是

Double quotes will not work with start; this starts a new command-line window instead.

更新1 :瓦埃勒Dalloul的解决方案工作。此外,如果
有URL连接codeD字符(如空间连接$ C $光盘作为
20%)的URL和的它是在一个批处理文件的那么'%'必须是
EN $ C $光盘作为'%%。这不是在本例的情况下

Update 1: Wael Dalloul's solution works. In addition, if there are URL encoded characters (e.g. space is encoded as %20) in the URL and it is in a batch file then '%' must be encoded as '%%'. This is not the case in the example.

例如,在命令行( 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 

在默认浏览器打开和这些错误在命令行窗口:

being opened in the default browser and these errors in the command line window:

'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

Platform: Windows XP 64 bit SP2.

推荐答案

&安培; 用于单独的命令。因此,你可以使用 ^ 来逃避&放大器;

& is used to separate commands. Therefore you can use ^ to escape the &.

这篇关于我如何逃脱在批处理文件&符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆