PDA

View Full Version : About using NSIS



Rocco
23-09-2010, 20:50
Hi! I'm new here, I just found ThinBasic few days ago and my first impression was "great job"! It's a nice programming tool, reminds me some Visual Basic 6 (even if it's not a RAD (yet... but why not turn it into a powerful RAD?)...

I tried the "ThinBundle", and the first lack I saw is the possibility to add a custom icon (sorry, but the default icon is quite ugly under Windows Vista).

I would like to share my method here. Using NSIS is a possibility. This program was designed to create setups for programs, but it can also be used to create standalone executables for interpreted programming languages like ThinBasic.

You can get it here if you don't know it.

http://nsis.sourceforge.net/Main_Page

The first thing to do is to collect all the required files and place it in the same directory as the script. For a UI program, you need :

thinbasic.exe
thincore.dll
zlib.dll
thinbasic_ui.dll
your script (tbasic or tbasicx).

And here is my NSIS script (creates an exe with icon, version info and even a splash screen... no less, no more!) :


Name 'ThinBasic EXE'
Icon 'icon.ico'

OutFile 'out.exe'
SilentInstall silent

VIProductVersion "1.0.0.0"

VIAddVersionKey "ProductName" "ThinBasic Test"
VIAddVersionKey "Comments" "Just a test"
VIAddVersionKey "CompanyName" "Rocco"
VIAddVersionKey "LegalTrademarks" ""
VIAddVersionKey "LegalCopyright" "© Rocco"
VIAddVersionKey "FileDescription" "ThinBasic Test"
VIAddVersionKey "FileVersion" "1.0.0"

Function .onInit
InitPluginsDir
SetOutPath $PLUGINSDIR
; Splash
File 'splash.bmp'
advsplash::show 2000 500 1500 -1 $PLUGINSDIR\splash

Delete $TEMP\splash.bmp
FunctionEnd

Section "Executable"

; Required files
SetOutPath $PLUGINSDIR
File 'test.tbasicx'
File 'thinbasic.exe'
File 'thincore.dll'
File 'zlib.dll'

; Extra DLLs
File 'thinbasic_ui.dll'

ExecWait '"$PLUGINSDIR\thinbasic.exe" "$PLUGINSDIR\test.tbasicx"'
SectionEnd

Some explanations :

It extracts in the temp directory (PLUGINSDIR means a temporary directory under %temp%).

To compile it, just right click and choose "Compile...".

NSIS is also easy to learn, and can handle even the most complex deployment scenarios. Experiment! :D

Petr Schreiber
24-09-2010, 09:27
Thanks for the tip and welcome here!

The changeable icon for bundles is in the road plan, but the developer for bundle has changed quite recently so it takes some time to incorporate the additions.

Regarding your proposal - is the %temp% directory named randomly? I am asking just because I wonder if it allows running multiple instances of the "NSIS Bundle".
That means - if I click 3 times on the icon of the created exe, will it run 3 independent copies of it, or is it single instance only?


Thank you,
Petr

Rocco
24-09-2010, 19:07
I forgot two lines in the script above, the first is a mistake, change


Delete $TEMP\splash.bmp
to

Delete $PLUGINSDIR\splash.bmp

And after the "ExecWait...", add


SetOutPath $TEMP

Adding this line will delete the temp folder that was created.

To answer your question, yes, it creates an unique folder in the %temp% directory. For example, I start the .exe and it creates "%temp%\nsl44.tmp" to extract files, and if I start it again, another folder "%temp%\nsm46.tmp".

There's also a possibility in NSIS to get a random file name, using "GetTempFileName" function. You can customize all the "installation" process.

To help creating .exe this way, we could create a ThinBasic GUI that calls NSIS and automatically compiles.

Michael Hartlef
24-09-2010, 20:49
Hello Rocco,

welcome to the forum. :)

Your NSIS tool looks nice. I am sure once Eros has time he will look into this.

Best wishes
Michael Hartlef

ErosOlmi
24-09-2010, 21:27
Ciao Rocco and welcome to thinBasic community forum.
For sure I will check your suggestion and see if it can be a viable solution for thinBasic.

Rocco
29-09-2010, 21:20
Ciao Eros, of course it's a temporary solution until a true "ThinBundle" with version info, icons will be available. But it does the work and the possibilities seems greater for now.