Write variables to file as %VAR% not as the value of the variable, as well ask making tasklist function properly when redirecting output.
Code im using to write to file:
echo tasklist /FI "IMAGENAME eq %ZOEXT%" 2>NUL | find /I /N "%ZOEXT%">NUL >> boot.bat
echo if "%ERRORLEVEL%"=="1" start /d "%ZODIR%" %ZOEXT% >> boot.bat
Result:
tasklist /FI "IMAGENAME eq Zoiper.exe"
if "0"=="1" start /d "C:\Documents and Settings\mgladman\Desktop\Zoip\Zoiper Communicator\" Zoiper.exe
What I want added to boot.bat:
tasklist /FI "IMAGENAME eq %ZOEXT%" 2>NUL | find /I /N "%ZOEXT%">NUL
if "%ERRORLEVEL%"=="1" start /d "%ZODIR%" %ZOEXT%
If you want i can publish whole code not just segment, it is a cool script 😛 Just has this small issue.
Only “workaround” i can think is to make the first script, to echo echo in the first file and write the correct system data (this has to be a portable script, so that would work, but would be messy as)
You can escape the
%using^if you are in command line.For example:
echoes
testechoes
%var%In batch file you have to use double % –
echoes
%var%