Solved How do you create a batch that creates another batch

March 29, 2019 at 16:27:08
Specs: Windows 10
I'm trying to make a batch create another batch into a specific location which it is not already in. Every time I use echo :start\nstart\ngoto start >> "C:\Windows\System32\Cmd.bat" it creates it into that folder but it does not put the line of code into new lines Ex: :start\nstart\goto start instead of

:Start
start
goto start


See More: How do you create a batch that creates another batch

Reply ↓  Report •

#1
March 31, 2019 at 11:25:49
✔ Best Answer
cmd.exe doesn't understand *nix-style escape characters. Certain characters can be escaped with a carat (^), but to my knowledge, a newline isn't one of them.

The easiest (best?) thing to do is to echo each line separately to the new batch, i.e.:

echo :start>>%target%
echo start>>%target%
echo goto start>>%target%

As an aside, I would like to point out that this specific batch will likely eventually crash the system by using all available memory. Also, naming it "cmd.bat" might have unintended consequences.


Reply ↓  Report •
Related Solutions


Ask Question