Creating batchfile with batchfile

Hi. I wanna make a batchfile that creates another batchfile with text. I've tried to use the echo command like this: "echo echo off > something.bat" and that do work but I need to use it like this:" echo ( echo off color a cls echo welcome etc. ) > something.bat somebody help! thanks in advance.

sort by: active | newest | oldest
1-10 of 16Next »
Is this what you are looking for?

@echo off
echo @echo off > "something.bat"
echo color a >> "something.bat"
echo cls >> "something.bat"
echo echo Welcome >> "something.bat"

Or try this one:

@echo off
color 0e
echo What do you want the title to be?
set /p title=
set /a line=1
echo What do you want line #1 to say?
set /p command=
echo %command% > "%title%.bat"
set /a line=%line +1
echo What do you want line #%line% to say?
set /p command2=
echo %command2% >> "%title%.bat"
goto two
matseng9 years ago
What you want to use is called a "Here document", but I'm almost 100% certain that dos/win batchfiles doesn't support that. What's wrong with using the standard output redirects? echo echo off > something.bat echo color a >> something.bat echo cls >> something.bat echo echo welcome >> something.bat
J.W (author)  matseng9 years ago
I need to put more than that in the file. When I compile my .bat files to .exe files, I can only include 1 file and I need to include 2, 1 .exe file and 1 .rar file so I have to create one of them using the echo method but it doesn't work, so.
echo doesn't do anything. and you can't really make a batch file that creates another batch file, unless you make something like a polymorphic virus
matseng J.W9 years ago
I think I lost you when you said that you want to include a exe and a rar-file in the batchfile... There's something that I don't understand here. If we focus on the expected outcome instead of a problem with a proposed solution it might be clearer to me. (I've used dos since 1982, version 1.25, so I've done most stuff that's possible with it during all these years....) So you have a bat-to-exe -compiler, and then you have three files that you want to integrate into one new exe-file? A batchfile, a rar-archive and a (premade) exe-file. Right? I must admit that I've never used a bat-to-exe compiler. If I want an exefile I use a real language for that, or back in the old days used Debug and created a com-file (a com-file is kind of a small lightweight exe-file) on the fly. What bat-to-exe -compiler are you using?
J.W (author)  matseng9 years ago
Yes I know what a .com file is I'm quite a pro with the ms-dos language, and I think I know very much more than u think. Download this file: http://www.download.com/3000-2069_4-10715331.html
Try it out and you'll see what I meen with including. The .exe that is created will create a file if included and that's very usable, but I need to include 2 files.
matseng J.W9 years ago
I didn't assume anything about your proficiency level, I just took a middle ground to be on the safe side. Anyhow... Why not just put both the exe and the rar-file into a sfx (self extracting archive) , 7-zip is a nice fee one, and include that file in the bat-to-exe-converter. Then as the first step in the batchfile run the sxf to generate both files. and then continue as usual. But you probably need to remove both files "manually" in the end of the batch since it is only cleaning up its own files after the run. I might still be missing something with how you actually want to use this....
J.W (author)  matseng9 years ago
Sure but the user still has to click "INSTALL" so.
matseng J.W9 years ago
Yes, you need a silent sfx extractor. This can be faked this way with 7-zip: @echo off echo Hello world! Now unpacking files start test.exe -y /Q echo Done. Press any key to end this batchfile pause The test.exe is the sfx with some files in it. I took the batchfile (above) and the test.exe-file and created an exe with the converter. And then ran the resulting file. It worked more or less perfectly. The only problem was that a small window was shown on the screen for like 0.1 seconds. I'm sure that there are some other sfx-creators that allows for completely silent and invisible extractions.
J.W (author)  matseng9 years ago
Nope doesn't work for me. Using winrar
1-10 of 16Next »