WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Compiler
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Embed Source Code

 Keywords:  Lost RecoverEmbed Source Script WBT WIL Code Compiled EXE Large Complete Other Files ExtractAttachedFile

There are time you would like to include the source code into your compiled EXE, in case the source code has somehow been lost. There are various methods to handle this. This is recommened:

In your source code, you will need to add some code to determine when to extract the source code. It could be either triggered by the existence of a particular file in the same directory as the EXE or via commandline.

The commandline trigger code might look something like this:

; Handle commandline input
; If user passes the commandline 'source' to the exe the .wbt file will be extracted tot he same directory as the exe.
If param0 > 0
   If param0==1
      If StrLower(param1)=="source"
         ExtractAttachedFile("main.wbt", "main.wbt")
      EndIf
   EndIf
EndIf

; Main code
Pause('Sample Source Extract', 'Pass the commandline parameter "source" to extract the source code')
For x = 1 To 100
   Yield()
Next
Exit
Now its time to compile your script.
  1. Launch the Compiler and choose the OPTION: Large Exes for standalone PCs.
  2. Select SOURCE: Main.wbt
  3. Select TARGET: Main.exe
  4. Select OTHER FILES: Add Main.wbt
  5. Select SETTINGS: Check the "Skip auto-extraction of extenders and other files from large EXE's" checkbox.
  6. In the main compiler dialog press OK to to compile.

Now if you run the Main.exe with no commandline parameters, the source code will not extract. If you pass th single commandline parameter "source" to the main exe the maint.wbt file should extract to the same directory as the Main.exe.

"C:\temp\Main.exe" "source"

Article ID:   W17695
Filename:   How to Embed Source Code.txt
File Created: 2013:04:05:11:51:52
Last Updated: 2013:04:05:11:51:52