Archive: Go back after Page InstFiles, run the installer again


Go back after Page InstFiles, run the installer again
  Hello,

I am trying to write an installer with two pages, a custom page using InstallOptions and the page InstFiles. After installing/updating some stuff, I need it to go back, expecting the user to give another input data. The user can close the program by pressing the Cancel button on the first page.

Unfortunately the Back button on the page InstFiles is disabled. The only working method that I found is Exec "$CMDLINE":

Function .onInstSuccess

Exec '$CMDLINE'
>FunctionEnd
>
but this way the program closes and reopens, and has to decompress everything once again. Another solution would be to add some more pages:

Page custom ShowCustom

Page InstFiles
Page custom ShowCustom
Page InstFiles
Page custom ShowCustom
Page InstFiles
>
but I don't want to have a limit - as the user may need to update one file or twenty-five.

For this goal, the global label ".onceagain:" in ShowCustom, called by .onInstSuccess isn't working.

The best thing would be to enable the "Back" button on the page InstFiles. Do you have any idea how it could be done? I would apreciate any other idea/method that would work.

Thank you very much for your attention.
Petko

I also tried some trikcs I found here, but maybe I'm still doing something wrong.


Page InstFiles showInst


>function showInst
GetDlgItem $R0 $HWNDPARENT 3
EnableWindow $R0 1
FunctionEnd
>
This actually enables the "Back" button before the end of the installation, but when the text "Completed" appears, the button is disabled again.

Hard situation here. You could create another installation just to enable the button, using Sleep and the lines of code to enable the button (only changing the hWnd by the real installer one which means that FindWindow $var "#32770" is necessary here). Run this second program before ending the installation.


Thank you for the idea, but doesn't seem to work as expected. When I push the Back button, instead of returning to the first custom page, it runs again directly the page InstFiles. Here is the script for back.exe, called as 'Exec "$PLUGINSDIR\back.exe $HWNDPARENT"'


"WinMessages.nsh"


>Name "back"
>OutFile "back.exe"

>Section main
SectionEnd

>Function .onInit
sleep 500
call GetParameters
Pop $R0

strCmp $R0"" skip
GetDlgItem $R1 $R0 3
IsWindow $R1 0 skip
EnableWindow $R1 1
goto end
skip:
MessageBox MB_OK "No valid window specified"
end:
abort
FunctionEnd
>Function GetParameters ;//as in the manual

It works!!!
  It works, finally, with an additional check how the page InstFiles is called:

Page custom ShowCustom LeaveCustom

Page InstFiles showInst

>Function LeaveCustom
StrCpy $R9 1
FunctionEnd
>function showInst
intcmp $R9 1 end
abort;not coming from the first page
end:
>FunctionEnd
Section main
StrCpy $R9 0
>; etc.
Thank you very much, deguix, for the tip. :up:

Need a better solution....
  I was hoping such a simple task as making the page go back was simpler than making an external utility...

Anybody have a better idea? (not requiring plugins?)

- Also could someone please summarize this post and show the code that "works". It's a little confusing here.


Also I can't seem to get this working. It does what you said before. It goes directly to the instfiles page (annoying). I even put the changes in you said to.

Also, I want back enabled only on error in installation.


Try this:

Use the Finish Page, but use the "Run" checkbox to be 'Run installation/again' option.
Then use deguix's Goto To NSIS page function here (http://nsis.sourceforge.net/Go_to_a_NSIS_page) in the Run function that it calls, to return to the custom InstallOptions page.

I have used a similar mechanism in an updater that updates multiple computers, so in my case the 'Run' box becomes an 'update another computer' box.

Duncan


I'm checking that out. Also I have gotten the code on this page working. <I>However</I> There are several mistakes.
'showInst' should really be a Pre function for INSTFILES page, not a show function.
A bug that I ran into was that the top says "Installation Aborted", and all the navigation buttons (except cancel) are disabled.


CORRECT SOLUTION!
  I have a working, and correct solution!

Uses deguix's RelGotoPage.

;this helps us navigate between pages. Cannot be called from a section or section function. Only pre-show-post functions can be callers. Won't work otherwise.


RelGotoPage   

Pop $R9
IntCmp $R9 0 0 Move Move
StrCmp $R9"X" 0 Move
StrCpy $R9 "120"

Move:
SendMessage $HWNDPARENT "0x408" "$R9" ""
>FunctionEnd
>
;$GOBACK is a custom global variable. Should be initialized to 1, indicating success.

.

${If}$GOBACK == 0 ; this special variable GOBACK is 1 when we come a successful install. Its "0" if an error occured in the section install.
StrCpy $R9 "<--NUMBER OF PAGES TO NAVIGATE(+,-), YOUR VALUE-->"
Call RelGotoPage
Abort
${EndIf}
Return
>FunctionEnd
>
;If you encounter an error ANYWHERE (most likely in a section. Set GOBACK to 0 and Return immediately.
; Aborting the section instead will cause all your navigation buttons to be disabled.
; Note that your Descript text at the top will still say "installing" when you go back to that page.
; I'm sure there is a way to fix this though.

- A drawback I know will occur is that the sections after your section with an error will continue to install. I am not sure how to prevent this. Perhaps checking that error flag (GOBACK) at the beginning of each section will tell us whether to install anything.

Shorin, sounds like you are on the right track.

You need to remember that when using RelGotoPage, it does not reset any of the variables that may have changed during the first pass of your installer (this includes any built-in/standard ones too), so you need to do this explicitly. For example, I use the RealProgress plugin, so I need to remember to reset my progress counters and unload/load/reset the RealProgress plugin before jumping back pages. My updater only has one section so I haven't seen your behaviour with multiple sections.

Also, petko, the problem of unpacking each run can be handled by unpacking for files into a directory in the $TEMP directory in the .onInit function, refer to your files during your install, and then remove them in the .onGUIEnd function.

Duncan