Archive: Newbie to NSIS and one question. ;)


Newbie to NSIS and one question. ;)
First of all, I am comming from Installshield. I used it for a multilanguage PocketPC application. But InstallShield EXE are rather big, installation for PocketPC isn't flexible (no way to modify INF files), ...

So I downloaded NSIS and the HM NIS editor yesterday to get an idea how it would work for me. Well, have to say I am pretty much impressed how "easy" it is. :up:
My setup with NSIS is up and running allready (EXE is half the size of IS with nearly same functionality). :D

There is just one issue left. Is there a default page/text for an upgrade warning, so warn the user that the program is allready installed? Most important for sure is the multilanguage functionality.


this is an example i've used in one of my scripts. it checks if nsis is installed on the system, unselects the component if it is and displays a messagebox if one wants to install it anyway.

please note that i used the .chm file to make sure it's a NSIS 2.0 installation. it's safer and more elegant to query the registry for existing installation keys, but in this case that wasn't enough.

also this might not be the perfect example, but it should be enough to figure out how it works. if you prefer a custom page over a messagebox, search the forum for custom pages.

Section "NSIS 2.0" NSIS2
SectionIn 1
StrCmp $NSIS "" Continue Message
Message:
MessageBox MB_YESNO "Setup detected a NSIS installation. Overwrite anyway?" IDNO End
Continue:
Call ConnectInternet
NSISdl::download /TIMEOUT=30000 "http://osdn.dl.sourceforge.net/sourceforge/nsis/nsis20.exe" "$TEMP\nsis20.exe"
IfFileExists "$TEMP\nsis20.exe" InstallNSIS Failed
Failed:
MessageBox MB_OK "Downloading NSIS from SourceForge.net failed or was aborted."
ExecShell open "http://prdownloads.sourceforge.net/nsis/nsis20.exe?download"
Goto End
InstallNSIS:
ExecWait "$TEMP\nsis20.exe"
Delete "$TEMP\nsis20.exe"
End:
SectionEnd

Function .onInit
ReadRegStr $NSIS HKLM "Software\NSIS" ""
IfFileExists "$NSIS\NSIS.chm" +1 End
!insertmacro UnSelectSection "${NSIS2}"
End:
FunctionEnd

for the multilingual installation, check the languages example, which comes with your nsis installation.

Thanks.
May I wasn't clear anough. The code to check older installations and tell the user I had allready but just english. I need the informational text for different languages. So I was hoping there is a page handling this with no need for me to translate to every needed language. ;)


You can use LangString to translate messages depending on the computer language.


Well, yes that helped.
Unfortunately there is an issue with language selection. If I change language during .onInit it isn't accepted within .onInit. It's changed not until the first install section. But I want to have the upgrade/update agreement dialog at very first, not walking all the installation pages.
I know the language (if prevously installed) from "NSIS:Language" even at .onInit, so that's not the issue. To point is, I do want to use the language the user had choosen, not the language NSIS chooses at startup. ;)
Any solution to that?


Take a look at my example. It demonstrates a completely functional multilingual install, containing the functionality you are requesting.


To point is, I do want to use the language the user had choosen, not the language NSIS chooses at startup.
You can use the LangDLL plugin. If you're using Modern UI, it's easy to implement that in your installer:

;--------------------------------
;Reserve Files

;These files should be inserted before other files in the data block
;Keep these lines before any File command
;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA

!insertmacro MUI_RESERVEFILE_LANGDLL

Function .onInit

!insertmacro MUI_LANGDLL_DISPLAY ;call LangDLL plugin

FunctionEnd

;--------------------------------
;Uninstaller Functions

; Use this if your installer has an uninstaller

Function un.onInit

!insertmacro MUI_UNGETLANGUAGE

FunctionEnd