Saving NSIS Install Log
Asked Answered
B

3

29

What's the easiest way to save the install log that is displayed in NSIS? I seem to remember reading somewhere that you can recompile the NSIS code with a special flag to enable it to save the log. Is there an easier way?

Begga answered 14/5, 2009 at 2:38 Comment(1)
Try Dump_log_to_file.Harpy
G
16

Try the NSISLog plugin.

There's also LogEx.

Gaige answered 14/5, 2009 at 2:57 Comment(0)
Z
42

In an attempt to keep file sizes small, the default installation of the NSIS compiler doesn't make log files. Download the Special Build of a release and copy it over the makensis.exe application (and Stub folder) to patch it to have logging support.

Once you have done that, simply add the following to your script:

 LogSet on 

No other changes are needed. I have no idea why this isn't default as in my cases, it only adds 48 bytes to the filesize!

Zsazsa answered 25/9, 2009 at 8:27 Comment(3)
Make sure to copy both the makensis AND the files in the Stub directory. I just copied the makensis.exe and everything works, but the install.log file was never created.Shaylynn
$INSTDIR must have a value before you call this function or it will not work. - from NSIS manualKaplan
Another pitfall : LogSet on has to be added to EVERY section and/or function where you want to log stuff (not just once)Moan
G
16

Try the NSISLog plugin.

There's also LogEx.

Gaige answered 14/5, 2009 at 2:57 Comment(0)
S
5

Here's a solution straight from the NSIS website

StrCpy $0 "$EXEDIR\install.log"
Push $0
Call DumpLog



!define LVM_GETITEMCOUNT 0x1004
!define LVM_GETITEMTEXT 0x102D

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
Sanorasans answered 14/5, 2009 at 2:55 Comment(2)
Does not work in silent mode, will not work if something failed. What's the reason for this kind of logging?Patricepatrich
@JackNova just remove the lvm_getitemcount declared on the topEason

© 2022 - 2024 — McMap. All rights reserved.