Adding del to file not working

November 19, 2011 at 09:02:11
Specs: Windows Vista
I have a batch that creates a batch file with text inside it, but when it gets to the del, it does not add the line to test.bat, causing the other lines to not respond correctly.

ECHO del "%%~2" ^> nul 2^>&1>>test.bat

Everything else works, just this part seems to be the problem.


See More: Adding del to file not working

Report •


#1
November 19, 2011 at 09:14:13
Adding a ^ before & fixed the problem.
 ECHO del "%%~2" ^> nul 2^>^&1>>test.bat


Report •

#2
November 19, 2011 at 09:43:13
You seem awfully interested in nesting other scripts inside of your scripts. Why?

How To Ask Questions The Smart Way


Report •

#3
November 19, 2011 at 09:56:16
I create files that create coding that I need faster instead of just coding it reguarlly.

I needed this for my MultiColor Batch Program.

:GenerateBatch
echo/ 2>Color%ran%.bat
ECHO @echo off>>Color%ran%.bat
ECHO title Color%background%%text% - Generated By MultiColor Batch - Donovansrb10>>Color%ran%.bat
echo SetLocal EnableDelayedExpansion>>Color%ran%.bat
ECHO for /F "tokens=1,2 delims=#" %%%%a in ('"prompt #$H#$E# & echo on & for %%%%b in (1) do rem"') do (>>Color%ran%.bat
ECHO   set "DEL=%%%%a">>Color%ran%.bat
ECHO )>>Color%ran%.bat
ECHO :: Placeholder>>Color%ran%.bat
ECHO call :GetColor %background%%text% "%input%">>Color%ran%.bat
ECHO echo/>>Color%ran%.bat
ECHO echo/>>Color%ran%.bat
ECHO echo Press any key to exit.>>Color%ran%.bat
ECHO pause ^>nul>>Color%ran%.bat
ECHO exit>>Color%ran%.bat
ECHO :GetColor>>Color%ran%.bat
ECHO ^<nul set /p ".=%%DEL%%" ^> "%%~2">>Color%ran%.bat
ECHO findstr /v /a:%%1 /R "^$" "%%~2" nul>>Color%ran%.bat
ECHO del "%%~2" ^> nul 2^>^&1 >>Color%ran%.bat
ECHO goto :eof >>Color%ran%.bat
goto OpenBatch


Report •

Related Solutions

#4
November 19, 2011 at 10:32:44
It's faster for you to embed a script inside of another script than just writing the script outside of a script? This is me confused, especially since the code you posted creates a non-working script and crashes.

How To Ask Questions The Smart Way


Report •

#5
November 19, 2011 at 13:41:17
The variables are set from the other coding inside of the file.

Report •

#6
November 19, 2011 at 17:37:45
And all those darned >>Color%ran%.bat at the end of every line. Yuck!

Save your fingers, try:

:GenerateBatch
(
echo/ 2
All the rest of the echo command lines without redirection
ECHO goto :eof
)>color%ran%bat
goto OpenBatch


Please come back & tell us if your problem is resolved.


Report •


Ask Question