Old 29th May 2019, 21:37   #1
clairealex
Junior Member
 
Join Date: May 2019
Posts: 2
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
clairealex is offline   Reply With Quote
Old 29th May 2019, 22:08   #2
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Remix:

DetailPrint/nsExec::ExecToStack/FileOpen/FileWrite
meoit is offline   Reply With Quote
Old 30th May 2019, 01:09   #3
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 881
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 

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 30th May 2019, 15:47   #4
clairealex
Junior Member
 
Join Date: May 2019
Posts: 2
Thank you!
clairealex is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
logging

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump