I am trying to get a variable, put that in between two set strings and finally open the concatenated string in Chrome. There is, however, part of the string that I am having issues with which I am presuming is due to the usage of special characters.
@echo off set loc=%1 set link1=https://query.yahooapis.com/v1/public/yql?q=select * from geo.places where text=' set link2='&format=json set linkdone=%link1%%loc%%link2% "chrome.exe" "%linkdone%" link2 ('&format=json) is giving issues here, when I echo after setting it. It is an empty string and the batch goes on to echo invalid drive specification which is due to the erroneous reading of link2 I would assume.
I have tried escaping it as ^'^&format^=json but it does not seem to work. The rest of the code (notably link1 without escapechars) seems to work fine.
set "VAR=value"(note the quotes); since the final command line also contains the variable value quoted, there is still no need for escaping; special characters lose their particular meaning when placed within""; finally, instead of%1you should state%~1...%-escape some characters within the queryselect * from geo.places where text=for the browser, like%20for space, or%3Dfor=, for example...