Archive: Dump Log to text file


Dump Log to text file
Hi,

I've made my first simple script that essentially just copies some files since I don't have to do any real tricky installation. It just makes it look considerably more presentable than a batch file ;-)

I used the function/script bit for dumping the log to a text file from the forum but it still doesn't happen. Obviously I'm doing something wrong but I can't think what it is. I'm guessing that either it's getting called at the wrong time or not at all. Could someone please give me a pointer as to what I'm doing wrong,

I've summarised my script below;

TIA

Jonathan

;start
!if ${Project} == "Project1"
Name "Blah"
OutFile "P:\Blah_Install.exe"
!endif

!if ${Project} == "Project2"
Name "BlahBlah"
OutFile "P:\Blah_Blah_Install.exe"
!endif

;-------------------------------------------------------------------------------
; Generic setup parameters for the installer

Icon "${NSISDIR}\Contrib\Graphics\Icons\arrow2-install.ico"
ShowInstDetails show
SetOverwrite ON
CRCCheck ON
FileErrorText "Can not write to file $\r$\n$0$\r$\n."
InstType "Full"
SetCompressor /SOLID lzma


!define LVM_GETITEMCOUNT 0x1004
!define LVM_GETITEMTEXT 0x102D


; Use the Modern User Interface
!include MUI2.nsh

;MUI Settings
!define MUI_ABORTWARNING

!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\arrow-install.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp"

!define MUI_WELCOMEPAGE_TITLE_3LINES

!define MUI_LICENSEPAGE_BGCOLOR /grey
!define MUI_LICENSEPAGE_CHECKBOX ;sets the checkbox before the I Agree button is un-greyed out

!define MUI_INSTALLFILE_COLORS /windows


;-------------------------------------------------------------------------------
;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "License.rtf"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

;-------------------------------------------------------------------------------
;Splash screen

Function .onInit
var /GLOBAL "Project"

SetOutPath $TEMP
File /oname=splash.bmp "C:\Program Files\NSIS\Contrib\Graphics\Splash\Splash.bmp"
splash::show 1500 $TEMP\splash

Pop $0 ; $0 has '1' if the user closed the splash screen early,
; '0' if everything closed normally, and '-1' if some error occurred.
Delete $TEMP\splash.bmp
FunctionEnd

;-------------------------------------------------------------------------------
;Installer Sections

Section "First File Set"
SectionIn 1 RO
SetOutPath "some path"
File A_File

SetOutPath "some other path"
File Another_File
SectionEnd

Section "Second File Set"
SectionIn 1 RO
SetOutPath "Yet Another Path"
File /r /x not_this_file.dat A_Path\*.*
File Path\to some\executable\Exec.exe
SectionEnd

Section "Last File Set"
SectionIn 1 RO
SetOutPath "more paths"
File more_files
SectionEnd

;-------------------------------------------------------------------------------
;Output Log

Section "-Output_log"
GetTempFileName $0
Push $0
Call DumpLog
SectionEnd


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 error
FileOpen $5 $5 "w"
StrCmp $5 0 error
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
Goto exit
error:
MessageBox MB_OK error
exit:
Pop $6
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
Exch $5
FunctionEnd


Where are the two !define's that should be in the script?

Stu


second block in the Generic setup section..

I assume you mean the lines

!define LVM_GETITEMCOUNT 0x1004
!define LVM_GETITEMTEXT 0x102D


Like I say I guess since it works for other people that I've got some or all of it in the wrong place is all.

J


OK, it's official, I'm too dumb to write scripts ;-/

Figured (by looking at some other dumplog posts) that it helps if I take out the GetTempFilename bit and just specify a path\filename in the push line, now it works! I knd of expected it to pop up a notepad window with the contents of the log instead of just writing it but I guess I can just open the created file using nsexec or something similar. I might even be able to figure it out myself :-)))

Thanks anyhow.

J