{"id":1824,"date":"2009-11-06T05:24:33","date_gmt":"2009-11-06T00:24:33","guid":{"rendered":"http:\/\/www.chiragmehta.info\/chirag\/?p=1824"},"modified":"2009-11-06T05:26:15","modified_gmt":"2009-11-06T00:26:15","slug":"how-do-i-escape-ampersands-in-batch-files","status":"publish","type":"post","link":"https:\/\/www.chiragmehta.info\/chirag\/2009\/11\/06\/how-do-i-escape-ampersands-in-batch-files\/","title":{"rendered":"How do I escape ampersands in batch files?"},"content":{"rendered":"<p><strong>Q: <\/strong>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?\u00a0Double quotes will not work with start; this starts a new command line window instead.<\/p>\n<ol>\n<li>&#8216;&amp;&#8217; is used to separate commands therefore you can use ^ to escape the &#8216;&amp;&#8217;<\/li>\n<li>Note that you need to supply a dummy first argument in this case, as\u00a0<code style=\"padding-top: 1px; padding-right: 5px; padding-bottom: 1px; padding-left: 5px; font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #eeeeee; font-family: Consolas, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New'; background-position: initial initial; margin: 0px; border: 0px initial initial;\">start<\/code> will treat the first argument as a title for the new console windows, if it is quoted. So the following should work (and does here):<\/li>\n<\/ol>\n<pre style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #eeeeee; font-family: Consolas, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New'; overflow-x: auto; overflow-y: auto; width: auto; max-height: 600px; background-position: initial initial; padding: 5px; border: 0px initial initial;\"><code style=\"font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #eeeeee; font-family: Consolas, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New'; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;\"><span style=\"font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; color: black; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;\">start <\/span><span style=\"font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; color: maroon; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;\">\"\"<\/span><span style=\"font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; color: black; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;\"> <\/span><span style=\"font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; color: maroon; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;\">\"http:\/\/www.google.com\/search?client=opera&amp;rls=en<\/span><\/code><\/pre>\n<p>Also note,if there are URL encoded characters (e.g. space is encoded as %20) in the URL and\u00a0<em>it is in a batch file<\/em> then &#8216;%&#8217; must be encoded as &#8216;%%&#8217;. This is not the case in the example.<\/p>\n<p>Source : <a href=\"http:\/\/stackoverflow.com\/questions\/1327431\/how-do-i-escape-ampersands-in-batch-files\" target=\"_blank\" rel=\"noopener\">http:\/\/stackoverflow.com\/questions\/1327431\/how-do-i-escape-ampersands-in-batch-files<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q: 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?\u00a0Double quotes will not work with start; this starts a new command line window instead. &#8216;&amp;&#8217; is used to separate commands therefore you can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[12],"class_list":["post-1824","post","type-post","status-publish","format-standard","hentry","tag-microsoft","post-preview"],"_links":{"self":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/comments?post=1824"}],"version-history":[{"count":3,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1824\/revisions"}],"predecessor-version":[{"id":1827,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1824\/revisions\/1827"}],"wp:attachment":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/media?parent=1824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/categories?post=1824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/tags?post=1824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}