hanenjom
24th June 2011 11:54 UTC
ProgressBar with silent silentMod
Hi,
please i use a silent mode for my installation, but I notied that installation is so silent , i don't have any sign, i would like using progress bar for user.
in my research I found the progress bar in a page, but my need is just a progress without page to have in idea for the progress installation.
Please help me.
Thx.
Afrow UK
24th June 2011 12:54 UTC
I would really suggest NOT having a progress bar. It really annoys me when I want to install a 3rd party program or run a 3rd party command line application with a silent switch that isn't silent. The whole point of a silent switch is so that the caller can manage progress while waiting for your process to complete, perhaps with a simple one line message.
But to answer your question, this can't be done properly (i.e. like the NSIS progress bar) because in silent mode there is no NSIS UI and so no progress messages are sent (PBM_SETPOS). You can still use a plug-in such as Banner or NXS to show a message to the user but again this defeats the purpose of a silent install.
Stu
hanenjom
24th June 2011 13:51 UTC
thx
thx for you answers
Anders
24th June 2011 17:49 UTC
This is ugly, but it sort of works:
!include LogicLib.nsh
!include FileFunc.nsh
Var SilentGUI
!define SILENTGUI_INSTJUMP 2 ;page jump from first page to instfiles
!define SWP_NOMOVE 0x0002
!define SWP_NOZORDER 0x0004
!define SWP_NOSIZE 0x0001
!define SWP_FRAMECHANGED 0x0020
Function .onGuiInit
${GetParameters} $0
ClearErrors
${GetOptions} $0 "/SilentGUI" $0
${IfNot} ${Errors}
StrCpy $SilentGUI 1
System::Call 'USER32::SetWindowLong(i $HWNDPARENT,i -16,i 0x800008C8|0x00400000)'
SendMessage $HWNDPARENT "0x408" "${SILENTGUI_INSTJUMP}" ""
${EndIf}
FunctionEnd
Function InstFilesShow
${IfNotThen} $SilentGUI <> 0 ${|} Return ${|}
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $9 $0 0x3EC
StrCpy $1 ""
hideloop:
FindWindow $1 "" "" $0 $1
ShowWindow $1 0
StrCmp $1 0 "" hideloop
ShowWindow $9 1
System::Call '*(i,i,i,i)i.r0'
System::Call 'USER32::GetClientRect(i $9,ir0)'
System::Call '*$0(i,i,i,i.r2)i'
System::Call 'USER32::GetClientRect(i $HWNDPARENT,ir0)'
System::Call '*$0(i,i,i.r1,i)i'
IntOp $3 $1 - 25
System::Call 'USER32::SetWindowPos(i $9,i,i0,i0,ir3,ir2,i ${SWP_NOZORDER})'
System::Free $0
IntOp $2 $2 + 25
System::Call 'USER32::SetWindowPos(i $HWNDPARENT,i,i,i,ir1,ir2,i ${SWP_NOMOVE}|${SWP_NOZORDER}|${SWP_FRAMECHANGED})'
FunctionEnd
Function InstFilesLeave
${If} $SilentGUI <> 0
Quit
Abort
${EndIf}
FunctionEnd
Section
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
SectionEnd
Page Components
Page Directory
Page InstFiles "" InstFilesShow InstFilesLeave
Run with setup.exe /silentgui