I want to create a windows batch
script, which will have a base64
encoded program included. By included I mean - the encoded program will be "hardcoded" - there should be a "function" (or a code block) which will write the file line by line.
(like in this question related to Linux Bash
: Bash script containing binary executable)
I want to ask you what is the best method to do something like this, when it should apply to the following points:
- I want to use only the tools bundled with Windows (no additional libraries, executables etc)
- The file should be single - It can simply include the
base64
encoded string in any way - I want t get the highet spossible performance
I've tried to convert each base64
encoded line to an echo call, but this is very slow. Echoing 6000 lines takes about 10 seconds (I want to generate a file whcih will have about 10 000 lines with this method).
Is there a better method to do this? Maybe there is a "file splitter" in windows, which will allow me to split this batch script and "extract" somehow some lines (like extract lines 100-10100) and save them to another file?
A part of currently used file generation is as follows:
:getbin_Windows_x86
[...]
echo f0VMRgIBAQAAAAAAAAAAAAIAPgABAAAAsCVAAAAAAABAAAAAAAAAAEiGBQAAAAAAAAAAAEAAOAAK>>%INSTALLER_BASE_TMP%
echo AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA>>%INSTALLER_BASE_TMP%
echo AAAMAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA>>%INSTALLER_BASE_TMP%
[...]
GOTO:EOF
I would love to do it using batch files, but if Power Shell
will give me some better result, I'll move over it.