You need to escape special characters, so the parser knows which parts you want to echo and which ones you want to be executed.
Btw. It's easier to redirect a complete block
(
echo mode con:cols=80 lines=28
echo @echo off
echo Title Error Log
echo :startLogObserve
echo type "%%UserProfile%%\Desktop\testLog.txt"
echo timeout /t 2 ^>NUL /noBreak
echo cls
echo goTo :startLogObserve
) > %UserProfile%\Desktop\observeLog.bat
I also changed the type %UserProfile%..
to type "%%UserProfile%%..."
else you get the expanded version in your observeLog.bat
The quotes are useful when %UserProfile%
contains spaces or special characters