Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 18th May 2020, 02:20   #1
Motti
Junior Member
 
Join Date: May 2020
Posts: 2
Two installations in one installer: Main app and host environment

On the NSIS Sourceforge site, there is this sample script for installing two software packages in one installer. I am trying to adapt it for my purpose, which is to install additional, ancillary software in a separate folder from the main install if the target machine is a Windows 32 system.

I am a newbie on NSIS and I'm having trouble understanding how that script works. Could someone publish a simpler, cut-down version of it, that -

- uses the older, simpler, non-MUI installer,
and is without -
- language selection
- the pages for the user to select components of the package to install
- the section below the comment "Please don't modify below here unless ..."

I am hoping that such a cut-down, simpler version will make it easier to understand and adapt it.
Motti is offline   Reply With Quote
Old 18th May 2020, 10:16   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,316
...but you still want to display two different directory pages?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st May 2020, 02:07   #3
Motti
Junior Member
 
Join Date: May 2020
Posts: 2
Yes, I do, because I am installing a 16-bit program that I wrote decades ago. In 32-bit Windows (nowadays a rarity), it runs seamlessly as a console app, so only my app needs to be installed, but if the target system is 64-bit Windows, the installation needs to include DosBox and some additions to its config file, hence the (conditional) need for two installations.
Motti is offline   Reply With Quote
Old 21st May 2020, 21:42   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,316
The example you linked to uses two InstFiles pages which is extra complicated and not really needed in your scenario.

The basics are really simple, just unselect the function in .onInit if you are on a x86 system. A bit more tweaking is required to get the directory pages to display the correct sizes.

PHP Code:
InstallDir "$ProgramFiles\MyApp"

!include LogicLib.nsh
!include x64.nsh
!include Sections.nsh
!include WinMessages.nsh

Var DosboxDir

Page Components
Page Directory MainDirPagePreCallback
PageEx Directory
    PageCallbacks DosBoxDirPagePreCallback
    DirVar $DosboxDir
    Caption 
": DOSBox directory"
PageExEnd
Page InstFiles

Function .onInit
StrCpy $DosboxDir 
"$ProgramFiles\DOSBox" ; Default DOSBox directory
Call ConfigureSectionsForPlatform
FunctionEnd

Section 
-Pre
Call ConfigureSectionsForPlatform 
Restore sections because we changed them for the directory pages
SectionEnd

Section 
"Main Application" SID_MAIN
SectionIn RO
SetOutPath $InstDir
File 
$%windir%\Explorer.exe Dummy file
SectionEnd

Section 
"DOSBox" SID_DOSBOX
SectionIn RO
SetOutPath $DosboxDir
File 
$%windir%\system32\regedit.exe Dummy file
SectionEnd

Function ConfigureSectionsForPlatform
!insertmacro SelectSection ${SID_MAIN}
${If} ${
IsNativeIA32}
    !
insertmacro UnselectSection ${SID_DOSBOX}
${Else}
    !
insertmacro SelectSection ${SID_DOSBOX}
${EndIf}
FunctionEnd

Function MainDirPagePreCallback
Call ConfigureSectionsForPlatform
!insertmacro UnselectSection ${SID_DOSBOX}
${If} ${
IsNativeIA32}
    
GetDlgItem $0 $hWndParent 1
    SendMessage 
$${WM_SETTEXT"" "STR:$(^InstallBtn)" Change the button text if there is no other pages before the InstFiles page
${EndIf}
FunctionEnd

Function DosBoxDirPagePreCallback
${If} ${IsNativeIA32}
    
Abort Skip the page
${EndIf}
Call ConfigureSectionsForPlatform
!insertmacro UnselectSection ${SID_MAIN}
FunctionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
multi-install

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump