Automated creating executables with parameters (licencing)

Just starting out? Need help? Post your questions and find answers here.
WriteView
New User
New User
Posts: 4
Joined: Tue Jun 05, 2012 2:43 pm

Automated creating executables with parameters (licencing)

Post 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
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Automated creating executables with parameters (licencin

Post 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
sorry for my bad english
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: Automated creating executables with parameters (licencin

Post by helpy »

Here a little test scenario:

The PB source code in main.pb

Code: 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!
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
WriteView
New User
New User
Posts: 4
Joined: Tue Jun 05, 2012 2:43 pm

Re: Automated creating executables with parameters (licencin

Post 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" :evil:
This is how I love it.
:D

Thanks a lot! You saved important life time 8)
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Automated creating executables with parameters (licencin

Post by c4s »

@helpy
That's a great example. Thank you!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: Automated creating executables with parameters (licencin

Post 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
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
r7mk4
User
User
Posts: 13
Joined: Tue Aug 02, 2005 2:23 pm

Re: Automated creating executables with parameters (licencin

Post by r7mk4 »

Thanks helpy and Josh!

Very usefull!
Post Reply