Reputation: 27
I need to create a batch file with code written in it from a batch file, so I tried this code:
Echo @echo off echo Hello pause > NewBatch.bat
But NewBatch.bat has all of those lines written in one single line. I kind of expected this this to happen, but is there any way I can make it write individual lines?
Upvotes: 0
Views: 48
Reputation: 6630
Easy:
set /p n=^
Rem Above 2 lines are needed
Echo @echo off%n%echo Hello%n%pause > NewBatch.bat
And to ever produce a new line simply use %n%
.
Mona.
Upvotes: 1
Reputation: 41234
If you really want it in one line then this is an option:
(Echo.@echo off&echo.echo Hello&echo.pause)>NewBatch.bat
and a convoluted option:
>NewBatch.bat Echo.@echo off&>>NewBatch.bat echo.echo Hello&>>NewBatch.bat echo.pause
Upvotes: 0