Sunday, October 21, 2012

Convert a Batch File (.bat) Into an Executable (.exe) File

Information   Information
TechGuide101 is moving to TechByStep.co.uk, all future updates will be made there. To ensure you are reading the most up-to-date information for this topic please go to http://techbystep.co.uk/convert-a-batch-file-bat-into-an-executable-exe-file/
Convert a Batch File (.bat) Into an Executable (.exe) File


Description:
In this How-to-Guide i am going to be using Quick Batch File Compiler.

Convert your batch files into an actual program (.EXE format) in one click. This program may be run on Windows 2000/2003/XP/Vista/7 without any limitations. An EXE file is much harder to casually reverse-engineer, so this could be a way to conceal a particular batch file's operations from an end user. Content of your batch file will be encrypted and protected from changes.
Quick Batch File Compiler also lets you set various resources in the .EXE file, such as its description, the
company name, version information and even the application icon. In additional, you may include any files to compiled exe file and use it during execution.



Main Features:

  • Save/Load Project Options.
  • Open context help for batch commands by pressing F1 in editor.
  • Embedded files: you can embed files to the compiled executable. These files will be decompressed before script execution and deleted on exit.
  • Can create Ghost applications without DOS window.
  • Allows you to select application icon.
  • Allows you to edit Version Info for EXE-file.
  • Protects contents of a batch file from the non-authorized change.
  • Hides contents of a batch file from viewing.
  • It is not necessary to be the programmer to create the program.
  • It may be useful for installation and automation tasks.
  • Highlight command's syntax is inside built-in editor.
  • Can compile any batch file to exe format compatible with 2000/XP/2003/Vista/Seven.
  • All compiled files royalty-free.

Important Information:
Always ensure you keep a copy of the original source code as you can’t change the script within the EXE once it is compiled



FAQ's:

How I can access embedded files from the script?
All embedded files will be extracted to the temporary folder before main script execution. %MYFILES% variable contains a path to this folder, so you can use it in batch commands.
For example: CALL "%MYFILES%\filename.here"

Script could not locate embedded files?
Don’t forget about double quotes for paths with spaces.

What are the limitations of Ghost mode?
Ghost application uses invisible window, so it not support user interaction. Don't use PAUSE and other commands that required user input.

How many files I can embed in an executable file?
QBFC is not a replacement for archivers like WinZIP or WinRAR, so I recommend you use too many embedded files. You can add up to approx 100 MB to keep optimum performance, larger files may cause long delays on start-up.



Compiling the Executable:

1. Open Quick Batch File Compiler (QucikBFC).

2. Now you have 2 options:
  • Drag your existing batch file into the source window.
  • Write your script in the source window.
Source Window is highlighted red below:
















3. Now that you have added/wrote your script you can now make any final adjustments if required within the source window.

4. Click on the 'Version Info' tab.

5. You can now add various pieces of information about your program, just ensure you tick the box that says ‘Include Version info into executable'.

Tick box is highlighted blue and Information fields are highlighted red below:
















6. Now click on the 'Embedded Files' tab.

7. Here you can add an 'Application Icon' and add any files you require embedding.
  • Note - The application icon needs to be a true icon file (.ico).
  • When referencing any embedded files, ensure you use the %MYFILES% environment variable.
Just click on Browse to add an application icon and click the plus sign to add any embedded files you require:















8. One final thing before you compile the executable, how do you want it to run?
  • As a ‘Console Application’ (This is the default setting – runs as the batch file itself would run).
  • As a ‘Ghost Application’ (Used for a silent install/run – see limitations of Ghost Mode in the FAQ’s).
    • How do i change the mode?
      • Click 'Options' and change the 'Output EXE type' to what you require.








9. Now click 'Build' and save the EXE.









10. You now have the batch script in an executable form.


Important Information:
Always ensure you keep a copy of the original source code as you can’t change the script within the EXE once it is compiled.




Related Posts/Articles