Page 1 of 1
Automated creating executables with parameters (licencing)
Posted: Wed Sep 26, 2012 7:02 am
by WriteView
Hi all,
I really found nothing but my problems should be quite common.
So sorry if it's easy to find and I just haven't used the right keywords.
Let's say I'm doing some software and I have a list of costumers.
I'm actually presenting the licence holder (entrys of this list) in the info-menue.
After doing a small bugfix or update I want to publish that update to all costumers.
Actually I change the name in the code manually und compile it for every costumer.
That's okay if you have just 10-20 entrys.
How can I do that automated. Let's say I want to use a xml or text file and every line has the name of the licence holder.
I saw that pbcompiler.exe has some parameters. Before I start coding a small tool to do that batched...
In the future I want to add some more parameters for checksum or codes for dongles within this "autobuilder" / "autocompiler".
Has anyone a better or "more professional" way to that?
Cheers WriteView
Re: Automated creating executables with parameters (licencin
Posted: Wed Sep 26, 2012 7:08 am
by Josh
Hi WriteView,
i'm sure, there are more possibilities than this:
- Have a look at Tools>Configure Tools
- - Write a small support application which create some pbi codesnippets, designed specially for each customer
- Write XInclude instructions in your main source, that inserts this snippets
- Push the compiler from your support application to create your exe
Re: Automated creating executables with parameters (licencin
Posted: Wed Sep 26, 2012 8:27 am
by helpy
Here a little test scenario:
The PB source code in
main.pbCode: Select all
EnableExplicit
CompilerIf Defined( CUSTOMER_INFO_NAME, #PB_Constant ) = #False
#CUSTOMER_INFO_NAME = "John Doe"
CompilerEndIf
CompilerIf Defined( CUSTOMER_INFO_SERIAL, #PB_Constant ) = #False
#CUSTOMER_INFO_SERIAL = "0123-4567-89AB-CDEF"
CompilerEndIf
Define info_message.s
info_message = GetFilePart(ProgramFilename())
info_message + #CRLF$ + "test program"
info_message + #CRLF$ + ""
info_message + #CRLF$ + "Registered for:"
info_message + #CRLF$ + #CUSTOMER_INFO_NAME
info_message + #CRLF$ + ""
info_message + #CRLF$ + "Serial Number:"
info_message + #CRLF$ + #CUSTOMER_INFO_SERIAL
MessageRequester( "INFO BOX", info_message )
The customer list in an text file
customer_list.txt:
Code: Select all
exe-name;firstname lastname;AAAA-1111-2222-3333
prog_1;Kilie Parish;1234-5678-9ABC-DEF0
prog_2;Nick Beverly;FEDC-BA98-7654-3210
Batch file
compile_customer_programs.cmd:
Code: Select all
@echo off
set pbcompiler="The\path\to\Compilers\pbcompiler.exe"
set pboptions=/XP /THREAD /UNICODE /USER
for /F "tokens=1,2,3 delims=;" %%i in (customer_list.txt) do (
%pbcompiler% main.pb %pboptions% /CONSTANT "CUSTOMER_INFO_NAME=%%j" /CONSTANT "CUSTOMER_INFO_SERIAL=%%k" /EXE "%%i.exe"
echo.
echo.
)
pause
Put all in the same directory and execute
compile_customer_programs.cmd
There is a little problem with the batch files: If you use special characters in the customer_list.txt (like german umlauts or other ...) the console window probably will not support them (depends on the used code page in console window and on the char set of the text file).
There are still some other ways to do this!
Re: Automated creating executables with parameters (licencin
Posted: Wed Sep 26, 2012 9:59 am
by WriteView
While coding a solution how Josh suggested helpy delivered the solution I thought about.
I really really love this forum. Never seen a place where you get such fast and a high level support.
I remember the time when I tried coding the atmega µcontrollers with assembler and the forum members answered every question with: "Look at the datasheet"
This is how I love it.
Thanks a lot! You saved important life time

Re: Automated creating executables with parameters (licencin
Posted: Wed Sep 26, 2012 10:26 am
by c4s
@helpy
That's a great example. Thank you!
Re: Automated creating executables with parameters (licencin
Posted: Wed Sep 26, 2012 10:31 am
by helpy
If you do not want to pass the information over the console because you need special characters oder even binary data, you can do it a bit different:
- create a folder "customers"
- create a separate file for each customer
- in the batch file parse the files in the customers directory
- pass the filename to pbcompiler with /CONSTANT "CUSTOMER_INCLUDE=include-file"
- use the constant #CUSTOMER_INCLUDE with XIncludeFile or in a data section with IncludeBinary
Further important information:
- If you are using #PB_Editor_CompileCount, #PB_Editor_BuildCount, #PB_Editor_CreateExecutable you should be aware of that pbcompiler does not know these constants!
- If you defined an icon in compiler options in IDE you have to pass this to the pbcompiler with option /ICON
- If you defined Constants in the IDE settings "Compiler Options => Constants" than you have to pass them to
- If you defined version info in settings "Compiler Options => Version Info" than you have to create an ressource file and pass it with option /RESOURCE
cu, guido
Re: Automated creating executables with parameters (licencin
Posted: Mon Dec 31, 2012 12:59 pm
by r7mk4
Thanks helpy and Josh!
Very usefull!