I'm trying to create a batch script which will create another batch script. The problem is that one of the lines doesn't add and instead redirects to another file when it encounters the redirect that I want to create.
@echo off
:: Pulls name variable from text file
set /p UN=<name.txt
::Begins creating sec.bat
echo @echo off >sec.bat
:: Creates a vbs script to say whatever the %UN% variable is previously set as to the user
echo echo set speech = wscript.CreateObject("SAPI.spVoice") >>temp.vbs >>sec.bat
echo set text=%UN%! >>sec.bat
:: This is where my error is happening. I want it to write the entire line
:: "echo speech.speak "%text%" >> temp.vbs" to sec.bat but it won't. It
:: instead writes the line in a file called temp.vbs
echo echo speech.speak "%text%" >> temp.vbs >>sec.bat
echo start temp.vbs >>sec.bat
echo timeout /t 1 >>nul >>sec.bat
echo del temp.vbs >>sec.bat
I've tried putting the lines individually in quotations but that causes it to write the quotations to the bat file as well and it does not work as intended.