Reputation: 3711
im working on a project where im using NSI to create a setup myproject.exe, everything works fine, but i want to dump the log that is displayed into a file, that also works fine, but my problem is i cant figure out when to call the log function
i have 12 sections in my script , i got the function to create the installation log from Dump log to file
!define PRODUCT_NAME "myApplication"
!define PRODUCT_VERSION "1.7.1"
!define LVM_GETITEMCOUNT 0x1004
!define LVM_GETITEMTEXT 0x102D
!include MUI2.nsh
Name "myExe"
OutFile "C:\myExe.exe"
InstallDir $PROGRAMFILES\myprojc
InstallDirRegKey HKCU "Software\myprojc" "Install_Dir"
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\Folder-Options.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\Banner.bmp"
; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;Languages
!insertmacro MUI_LANGUAGE "English"
BrandingText "myProj version 1.7.1"
;Here My section are decribed.. 12 of them
Section "main program and components" section1
;main promgram files are copied
SectionEnd
Section "other DLL" section2
;copy the DLLs
SectionEnd
Section "Text files" section3
;copy the required txt files
SectionEnd
;-....
;...
Section "install BDE admin" section12
;copy install BDE admin
;Calling the Dumplog function to create the log file
StrCpy $0 "$INSTDIR\Query\Presleyinstall.log"
Push $0
Call DumpLog
SectionEnd
;The function dumps the to a log file
Function DumpLog
Exch $5
Push $0
Push $1
Push $2
Push $3
Push $4
Push $6
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1016
StrCmp $0 0 exit
FileOpen $5 $5 "w"
StrCmp $5 "" exit
SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6
System::Alloc ${NSIS_MAX_STRLEN}
Pop $3
StrCpy $2 0
System::Call "*(i, i, i, i, i, i, i, i, i) i \
(0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1"
loop: StrCmp $2 $6 done
System::Call "User32::SendMessageA(i, i, i, i) i \
($0, ${LVM_GETITEMTEXT}, $2, r1)"
System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)"
FileWrite $5 "$4$\r$\n"
IntOp $2 $2 + 1
Goto loop
done:
FileClose $5
System::Free $1
System::Free $3
exit:
Pop $6
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
Exch $5
FunctionEnd
Since i have called the dumplog function in section 12, the log file is only create when/if the section is selected by the user, if the section 12 is not selected then the dumplog function wont be called and log file will not be created,
so please tell me how do i call the dumplog function irrespective of the section is selected or not by the user, That is call the dumplog when the installation is complete.
EDIT
i can also try to create a section "Create installer log" and check it and disable like
Section "Create installer log" section13
SectionIn RO
StrCpy $0 "$INSTDIR\myinstall.log"
Push $0
Call DumpLog
SectionEnd
this
but is there a way to call the dumplog function without section, and at the end of the installation?
Upvotes: 2
Views: 2272
Reputation: 127
You can even put it in callback functions.
Function .onInstSuccess
;..
Call DumpLog
;..
FunctionEnd
Function .onInstFail
;..
Call DumpLog
;..
FunctionEnd
Upvotes: 1
Reputation: 101636
If you don't give the section a name (or start the name with -
) then it will not be displayed on the components page:
Section "Foobar"
;Install the optional Foobar
SectionEnd
Section
;Hidden section
Section
Upvotes: 2