1.

Solve : Batch File Error.?

Answer»

I am having some trouble making a batch file that writes the "&" character onto a vbs file.
Normally i WOULD do something like:
echo off
echo HELLO, how OLD are you?
set /p age=
echo What is your name?
set /p name=
echo You are %AGE% & your name is %name% > file.txt
exit
That is just an example but I want to know if either you can make cmd ignore the "&" so it doesn't try to run "your" as a COMMAND, or if there is a REPLACEMENT for "&" in VBscript.
To write certain special characters from a batch we have to prefix them with an escape character. For the ampersand (&) this is a caret (^) thus you would need to put this in your batch file

echo You are %AGE% ^& your name is %name% > file.txt

Table of special characters and how to escape them

http://www.robvanderwoude.com/escapechars.php
Thanks, it worked!



Discussion

No Comment Found