Announcement

Collapse
No announcement yet.

Generate an installation log

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • clairealex
    replied
    Thank you!

    Leave a comment:


  • JasonFriday13
    replied
    Ages ago I wrote a function that dumps the install log to a file (NSIS 3.0+).

    Usage: ${DUMPLOG} "C:\path\to\file.log"
    Put it at the end of your install, I prefer using a hidden section after all the other sections.

    PHP Code:
    Original function borrowed from the NSIS user manual
    ; and modified for both Ansi and Unicode.
    !
    define DUMPLOG '!insertmacro DUMPLOG'
    !macro DUMPLOG file

    !ifndef LVM_GETITEMCOUNT
      
    !define LVM_GETITEMCOUNT 0x1004
    !endif
    !
    ifdef LVM_GETITEMTEXT
      
    !define _temp_item ${LVM_GETITEMTEXT}
      !
    undef LVM_GETITEMTEXT
    !endif
    !
    ifdef NSIS_UNICODE
      
    !define LVM_GETITEMTEXT 0x1073
      
    !define _WRITEBOM 'FileWriteWord $5 0xfeff' Write the BOM
      
    !define _FILEWRITE FileWriteUTF16LE
    !else
      !
    define LVM_GETITEMTEXT 0x102D
      
    !define _WRITEBOM Nop BOM doesn't apply to ansi text files
      !define _FILEWRITE FileWrite
    !endif

      Push $0
      Push $1
      Push $2
      Push $3
      Push $4
      Push $5
      Push $6
      
      StrCpy $5 ${file}
      FindWindow $0 "#32770" "" $HWNDPARENT
      GetDlgItem $0 $0 1016
      StrCmp $0 0 exitDumpFile
      FileOpen $5 $5 "w"
      ${_WRITEBOM}
      StrCmp $5 "" exitDumpFile
        SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6
        StrCpy $2 0
        System::Call "*(&t${NSIS_MAX_STRLEN})p.r3"
        System::Call "*(i0,i0,i0,i0,&i${NSIS_PTR_SIZE} 0,p$3,i${NSIS_MAX_STRLEN},i0,p0)p.r1" ; NSIS_PTR_SIZE is used to align the pszText member on x64
        loopDumpFile: StrCmp $2 $6 doneDumpFile
          System::Call "User32::SendMessage(p$0,i${LVM_GETITEMTEXT},p$2,pr1)p"
          System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)"
          ${_FILEWRITE} $5 "$4$\r$\n"
          IntOp $2 $2 + 1
          Goto loopDumpFile
        doneDumpFile:
          FileClose $5
          System::Free $1
          System::Free $3
      exitDumpFile:
        Pop $6
        Pop $5
        Pop $4
        Pop $3
        Pop $2
        Pop $1
        Pop $0

    !undef _WRITEBOM
    !undef _FILEWRITE
    !ifdef _temp_item
      !undef LVM_GETITEMTEXT
      !define LVM_GETITEMTEXT ${_temp_item}
      !undef _temp_item
    !endif

    !macroend 

    Leave a comment:


  • meoit
    replied
    Remix:

    DetailPrint/nsExec::ExecToStack/FileOpen/FileWrite

    Leave a comment:


  • clairealex
    started a topic Generate an installation log

    Generate an installation log

    Hello, I would like to know if there is a switch available to generate a log at install/uninstall time, when running an installer written with NSIS.
    Thank you!
    Claire
Working...
X
😀
🥰
🤢
😎
😡
👍
👎