Page 1 of 1

echo the "&" symbol to text file

Posted: 27 Sep 2011 12:56
by GRock84
ive have been working at this for several hours now and am stuck.
how in the **** do you echo the "&" symbol to text file? I am using a batch file to copy code to a text file and save it as a .vbs script.
i have:
echo navOpenInBackgroundTab = &h1000>>loginstart.vbs

echo set oIE = CreateObject("InternetExplorer.Application")>>loginstart.vbs

echo oIE.Navigate2 "http://blogs.msdn.com">>loginstart.vbs

echo oIE.Navigate2 "http://blogs.msdn.com/tonyschr",>>loginstart.vbs

echo navOpenInBackgroundTab>>loginstart.vbs

echo oIE.Navigate2 "http://blogs.msdn.com/oldnewthing",>>loginstart.vbs

echo navOpenInBackgroundTab>>loginstart.vbs

echo oIE.Navigate2 "http://blogs.msdn.com/ericlippert",>>loginstart.vbs

echo navOpenInBackgroundTab>>loginstart.vbs

echo oIE.Visible = true>>loginstart.vbs

everything else copies to the "loginstart.vbs", except "navOpenInBackgroundTab = &h1000". I have found that it is due to the "&" symbol. I have tried wrapping that line in quotations. It works, however, it copies the quotations to the file as well, thus rendering the file dysfunctional. how can I successfully copy that symbol without any additional text appearing in the file?

Re: echo the "&" symbol to text file

Posted: 27 Sep 2011 13:10
by dbenham
You will run into similar problems with additional special characters such as > < | ^

The solution is simple - the special characters need to be escaped using ^

Code: Select all

echo navOpenInBackgroundTab = ^&h1000>>loginstart.vbs

Dave Benham

Re: echo the "&" symbol to text file

Posted: 27 Sep 2011 13:26
by GRock84
Dude you're my hero! Thanks a lot!