Quick Batch File Compiler is the only real compiler that turns regular BAT scripts into real executable EXE files, not launchers that unpack the script into a temporary folder. However, it does have the ability to embed files directly into the EXE, but for other purposes. This feature is called Embedded Files, and it allows you to add everything that is necessary for the program to work:
All this is stored inside the EXE itself as a ZIP archive, and is unpacked only during the program launch. And after the end of the work, it is deleted, leaving the system clean.
When you compile a script to EXE, the program creates a separate section at the end of the file where you can store any data. This works like a ZIP archive, but of the embedded type, without the need for external installation or additional dependencies.
The files you add through the "Embedded Files" tab are saved in this internal storage. During startup, they are automatically extracted to a temporary folder, from where your script can use them.
Interesting fact: this technology is often used in modern installers. For example, when you run the installation file, it does not require the Internet, because everything necessary is already built into the program itself.
Embedded files are not encrypted, and thanks to the standard compression algorithm, they are easily checked by antiviruses so as not to cause false positives.
To use this feature, open the "Embedded Files" tab in the Quick Batch File Compiler interface. Here you can add any files or entire folders that will be embedded in your application.
Step 1. Adding filesClick the "Add" button, select the desired items: text files, images, binaries, even entire directories. Starting with version 5.3, adding entire folders, including subfolders, is supported. This is especially useful if some files may have the same name.
The program automatically packs everything into a ZIP archive, which becomes part of the EXE. When launched, these files are extracted to the specified location, and your script can access them.
Step 2. Selecting the unpacking locationAfter adding the files, it is important to choose where they will be unpacked. You have three options:
Personally, I usually choose TEMP, because it does not cause permissions problems, and the system automatically clears it on reboot.
After the program is launched, all embedded files are unpacked into a predefined folder. To access them, you can use the special environment variable %MYFILES%. It points to the temporary directory where your files were extracted.
For example, if you added a help.txt file, you can write in the script:
TYPE "%MYFILES%\help.txt" PAUSE
This will show the contents of the file directly on the command line. If the text is long, it is better to use:
MORE "%MYFILES%\help.txt"
This breaks the output into pages and makes it more convenient to read.
Please, never forget about double quotes around the file name. If you do not do this, any path containing a space will break your script.
If you add multiple files from different folders and they have the same name, Quick Batch File Compiler does not lose them. It handles such situations gracefully by creating unique subdirectories to avoid overwriting.
For example, if you add two files:
C:\Project\config\settings.ini D:\Tools\settings.ini
Both files will be included, but each will be in its own temporary folder. This way, you can use both without worrying about name collisions.
In case multiple copies of the same executable are launched, there is a collision protection mechanism. To prevent one copy from deleting files from the others, the files are not unpacked directly into the temporary folder, but into a subfolder with a unique name. This is why it is important to always use the %MYFILES% variable, not %TEMP% or %APPDATA%.
After your script finishes running, all embedded files are automatically deleted to avoid cluttering your system with temporary data.
However, if you run a third-party program that continues to use the files, the deletion may not occur. For example, if you open a PDF or media file and the program remains active, the files will not be deleted until the external application closes.
To avoid such situations, use the CALL command to make the script wait for the external program to finish before continuing. For example:
START "" /WAIT "%MYFILES%\manual.pdf" CALL "%MYFILES%\music_player.exe"
This way, the script will wait until it finishes working with the file, and the temporary data will be deleted correctly.
Add only those files that are really needed. The less unnecessary data in the EXE, the faster it will run.
Do not use the current folder as an unpacking location if you are working with limited rights. Sometimes users run programs from protected directories, and writing there is impossible.
You can even embed executable files, such as ffmpeg.exe, curl.exe or netcat.exe. This allows you to create completely autonomous utilities that work without installation.
Watch the size - the more files you add, the larger your EXE will be. For large projects, it is better to use external dependencies.
Embedded Files are one of the most powerful features of the Quick Batch File Compiler. They allow you to create completely standalone applications that do not require any additional dependencies. You can add all what you need: scripts, media files, utilities, help files.
With the %MYFILES% variable, you always know where to look for these files, even if you do not know from which place the user will launch your application.
The main thing is to correctly configure the unpacking location and ensure that all external processes are completed before the script finishes running, otherwise the temporary files will not be deleted.