- NSIS Discussion
- two directory pages question
Archive: two directory pages question
jaschulz
11th October 2003 15:56 UTC
two directory pages question
I want two directory pages in the installer, one for the program and one for the data files. I have this:
!define MUI_DIRECTORYPAGE_TEXT '"SetUp will install ${PRODUCT} in the Destination Folder \
shown below.$\r$\n$\r$\nTo select a different Destination Folder, Click Browse..." \
"Destination Folder: "'
!define MUI_PAGE_HEADER_TEXT "Program Install Location"
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_DIRECTORYPAGE_VARIABLE ${DATAINSTDIR}
!define MUI_PAGE_HEADER_TEXT "Data Install Location"
!define MUI_DIRECTORYPAGE_TEXT '"SetUp will install the ${PRODUCT} data files in the Destination Folder \
shown below.$\r$\n$\r$\nTo select a different Destination Folder, Click Browse..." \
"Destination Folder: "'
!insertmacro MUI_PAGE_DIRECTORY
but that gets me an error on the second call to MUI_PAGE_DIRECTORY
What am I doing wrong?
Thanks.
JAS
P.S. ${DATAINSTDIR} is set to the My Documents folder in .OnInit
Joost Verburg
11th October 2003 16:13 UTC
Thanks, fixed.
jaschulz
11th October 2003 16:57 UTC
OK, but when I try to do NSIS update, it complains as follows:
Initializing CVX update...
cvs95 update: Empty password used - try 'cvs login' with a real password
cvs95 update[aborted]: Error reading from server cvs.sourceforge.net: 0
Joost Verburg
11th October 2003 20:26 UTC
Hopefully the NSIS project will be moved to the new CVS servers next week. The current public CVS data is very old, so in the meanwhile, use a development snapshot.
jaschulz
11th October 2003 20:45 UTC
OK. I downloaded the snapshot and ran the compiler again. This time I got a new error. In my "pages" section, the compiler complains at the marked line (below) the MUI_PAGE_HEADER_TEXT is already defined.
here is my "pages" section (the error line is marked with ***ERROR***)
;--------------------------------
;Pages
!define MUI_WELCOMEPAGE_TITLE "SetUp: ${PRODUCT} ${VERSION}"
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of \
${company}'s ${PRODUCT} software.\r\n\r\n\ We recommend that you close any currently \
running programs before proceeding with this installation. This should make \
it possible to update relevant system files without requiring you to reboot your \
computer. \r\n\r\n\ Click Next to begin the installation process."
!insertmacro MUI_PAGE_WELCOME
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_LICENSEPAGE_CHECKBOX_TEXT "I accept all the terms of the License Agreement."
!define MUI_LICENSEPAGE_TEXT_TOP "Please review the all terms of the License Agreement: "
!define MUI_LICENSEPAGE_TEXT '"If you accept all the terms of the License Agreement, \
check the box below and then click CONTINUE \
to proceed with the installation." "CONTINUE"'
!define MUI_PAGE_HEADER_TEXT "License Agreement"
!define MUI_PAGE_HEADER_SUBTEXT "${COMPANY} ${ADDRESS}"
!insertmacro MUI_PAGE_LICENSE "gaLicense.txt"
***ERROR*** !define MUI_PAGE_HEADER_TEXT "Program Install Location"
!define MUI_DIRECTORYPAGE_TEXT '"SetUp will install ${PRODUCT} in the Destination Folder \
shown below.$\r$\n$\r$\nTo select a different Destination Folder, Click Browse..." \
"Destination Folder: "'
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_DIRECTORYPAGE_VARIABLE ${DATAINSTDIR}
!define MUI_PAGE_HEADER_TEXT "Data Install Location"
!define MUI_DIRECTORYPAGE_TEXT '"SetUp will install the ${PRODUCT} data files in the Destination Folder \
shown below.$\r$\n$\r$\nTo select a different Destination Folder, Click Browse..." \
"Destination Folder: "'
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; !define MUI_FINISHPAGE_TEXT_REBOOTNOW "Reboot the computer now?"
; !define MUI_FINISHPAGE_TEXT_REBOOTLATER "Reboot the computer later?"
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\TE.chm"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show Installation Help"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
Joost Verburg
11th October 2003 21:49 UTC
That's what I just fixed, are you sure your snapshot already contains the latest file? The snapshot is being updated 4 times a day.
jaschulz
11th October 2003 22:29 UTC
The change log says there was a fix at 15:25 and the snapshot I just downloaded (which still gives the error) says 17:46
jaschulz
12th October 2003 16:26 UTC
I downloaded the snapshot this morning (Sunday), but I am still getting the same error (at macro line 23) as before. Just to be sure, before I downloaded the snapshot this morning, I entirely deleted my NSIS files, but it didn't help. Am I doing something wrong here?
JAS
Joost Verburg
12th October 2003 20:18 UTC
Works fine for me. Can you attach your entire script?
jaschulz
12th October 2003 20:27 UTC
Sure. Here it is.
Joost Verburg
12th October 2003 21:13 UTC
MUI_DIRECTORYPAGE_VARIABLE should be a variable like $R0 or $MYVAR (defined using the Var command). Then you can use StrCpy to set the default value in .onInit.
jaschulz
12th October 2003 22:30 UTC
Thanks. I got it to work now. I would suggest there should be something in the docs about this.
bugfix
22nd October 2003 21:13 UTC
I would appriciate to have the final working script for this.
I have been looking for an example of this in a very long time.
So please upload the final running script
THANX
jaschulz
23rd October 2003 18:20 UTC
OK. Here it is:
;NSIS Modern User Interface version 1.66
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
;--------------------------------
;Configuration
;General
Name "Test NSIS"
var DATAINSTDIR
!define VERSION "v. 1.0"
!define PRODUCT "Test NSIS"
!define SHORT_PRODUCT_NAME "TN"
!define COMPANY "WiseWare"
!define ADDRESS "PO Box 2678780 Chicago, IL 60626-7870"
!define COPYRIGHT "Copyright © 2003 by ${COMPANY}"
Caption "${PRODUCT} ${VERSION}"
OutFile "TestNSIS.exe"
;Folder selection page
InstallDir "$PROGRAMFILES\${COMPANY}\${PRODUCT}"
;Get install folder from registry if available
InstallDirRegKey HKCU "Software\${COMPANY}\${PRODUCT}" ""
;--------------------------------
;Modern UI Configuration
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "License.txt"
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_DIRECTORYPAGE_VARIABLE $DATAINSTDIR
!define MUI_PAGE_HEADER_TEXT "Data Install Location"
!define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to install the ${PRODUCT} data files."
!define MUI_DIRECTORYPAGE_TEXT '"SetUp will install the ${PRODUCT} data files in the Destination Folder \
shown below.$\r$\n$\r$\nTo select a different Destination Folder, Click Browse..." \
"Destination Folder: "'
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Functions
Function .onInit
ClearErrors
ReadRegStr $0 HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" Personal
StrCpy $DATAINSTDIR "$0\${PRODUCT}"
FunctionEnd
;--------------------------------
;Installer Sections
Section "${SHORT_PRODUCT_NAME}.exe" SecCopyUI
;Establish install folder
SetOutPath "$INSTDIR"
;Extract the program file
File "${SHORT_PRODUCT_NAME}.exe"
;Establish data folder
SetOutPath "$DATAINSTDIR"
;Extract the data file
File "${SHORT_PRODUCT_NAME}.DAT"
;Write Registry Keys
WriteRegStr HKCU "Software\${COMPANY}\${PRODUCT}" "" $INSTDIR
WriteRegStr HKCU "Software\${COMPANY}\${PRODUCT}" "DataDir" $DATAINSTDIR
;Add Application to Add/Remove Programs
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "DisplayName" "${PRODUCT}"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString" '"$INSTDIR\Uninstall${SHORT_PRODUCT_NAME}.exe"'
WriteRegDWord HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "NoModify" 1
WriteRegDWord HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "NoRepair" 1
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall${SHORT_PRODUCT_NAME}.exe"
SectionEnd
;--------------------------------
;Uninstaller Section
Section "Uninstall"
;Delete the program
Delete /REBOOTOK "$INSTDIR\${SHORT_PRODUCT_NAME}.exe"
;Delete the uninstaller
Delete "$INSTDIR\Uninstall${SHORT_PRODUCT_NAME}.exe"
;Remove the install folder
RMDir "$INSTDIR"
; Delete the registry keys
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
DeleteRegKey /ifempty HKCU "Software\${COMPANY}\${PRODUCT}"
DeleteRegKey /ifempty HKCU "Software\${COMPANY}"
SectionEnd