Archive: Skip a built-in page using a custom page?


Skip a built-in page using a custom page?
I'm trying to make a custom uninstall page using InstallOptions 2. Well - actually, I'm succeeding in doing that, but not in making it do what I want:

On this custom uninstall page, I give the user two options using radiobuttons. The page works, and the radiobuttons appear, but it doesn't do what I want it to do.

This is what I want to happen:

If one option is chosen, the uninstall is to go on as usual, no change.
If the other option is chosen, I want the uninstall process to essentially be skipped, replacing the uninstall process with only removing a few files and some registry entries, instead of going through all the uninstall Sections.


So I have tried a couple of things in order to make this happen, but it doesn't quite work.

As mentioned, the custom uninstall page does appear, it looks how I want it to look, but it doesn't seem to do much.


So in my latest attempt, I have instead made a custom function with the page commands in it. I have then used this function in a !define MUI_PAGE_CUSTOMFUNCTION_PRE before the !insertmacro MUI_UNPAGE_INSTFILES in order to skip it.

What this did, was to show the custom page, but then all three buttons on the custom page were greyed out (Back, Uninstall and Cancel), so I was forced to do a Ctrl+Alt+Delete to quit the uninstaller process.


Before that, I have tried to just make an UninstPage custom, which calls Abort if a certain option is chosen, but that doesn't make the uninstaller skip the next built-in page (which is the UNPAGE_INSTFILES page).

Here's how the function that caused the buttons to be greyed out looks:


LangString TEXT_IO_HEADER ${LANG_ENGLISH} "Please decide what you will do next:"
LangString TEXT_IO_SUBHEADER ${LANG_ENGLISH} "-Are you going to uninstall the game as well?"

Function un.QuickUninstall ;Used to skip uninstall page

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_HEADER)" "$(TEXT_IO_SUBHEADER)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "UninstallOptions.ini"
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "UninstallOptions.ini" "Field 2" "STATE"
StrCmp $R0 1 done

messagebox MB_OK "Here is where it's supposed to skip the page and remove a few registry entries."
Abort
done:
FunctionEnd



Then in the uninstall macros it looks like this:

!define MUI_PAGE_CUSTOMFUNCTION_PRE un.QuickUninstall
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH


The messagebox will be replaced by the code to remove the registry entries and few files I want to remove when that option is chosen, once I get this script to work the way I want.


Again - I have also tried the other route by making a Page custom above the UNPAGE_INSTFILES, but it didn't do anything either: the message box appears, but when I click OK, the uninstall continues as usual. I want it to "jump over" the uninstall process when that option is chosen, and replace that with only removing a few files and registry entries instead.

All the script attempts I have made have been compiled without warnings, so the scripts "work" in that sense.

Hope you are able to understand what I want to do.

I know how to skip pages and have done that before, but not from a custom page like this.

Is it possible somehow?

Use MUI_INSTALLOPTIONS_READ in the custom pages' LEAVE function.

UninstPage Custom [CreateFunc] [LeaveFunc]

-Stu


OK, cheers - I'll see what I can do with that info. :)


OK - I have now tried this.

I "divided" the custom page function I had into two, so that one function displays the page, and the other carries out the work, so to speak:


LangString TEXT_IO_HEADER ${LANG_ENGLISH} "Please decide what you will do next:"
LangString TEXT_IO_SUBHEADER ${LANG_ENGLISH} "-Are you going to uninstall the game as well?"

Function un.QuickUninstall ;"QuickUninstall" defined with Page command

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_HEADER)" "$(TEXT_IO_SUBHEADER)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "UninstallOptions.ini"

FunctionEnd

Function un.QuickUninstall_2

!insertmacro MUI_INSTALLOPTIONS_READ $R0 "UninstallOptions.ini" "Field 2" "STATE"
StrCmp $R0 1 done

messagebox MB_OK "This is where the uninstaller is supposed to skip a page and remove some files etc."
Abort
done:

FunctionEnd


So the custom page macro now looks like this:
UninstPage custom un.QuickUninstall un.QuickUninstall_2

But when I use the resulting uninstaller, and get to that custom page, I choose the option that will result in a page skip and the messagebox. This is the default option, btw.

What happens then when I click the Uninstall button, is that the messagebox pops up, I click OK, but then nothing more happens. The next page isn't skipped, and I don't get to the next page at all. I'm still on the same page, and nothing happens.

I guess that if I had replaced the messagebox with the actual code to remove the files etc., that would have happened, but then I'd still be on the same page and kinda not get anywhere? What I need to happen is that I click the Uninstall button, some files are removed, the unintall page is skipped, and the Finish page opens.


I'm sure I'm doing something wrong here, so I could need another nudge in the right direction.

Thanks.

If you read the documentation, Abort when called in a pages' LEAVE function will push the user back to that page, not skip the next one. To skip the next page you need to call Abort in the next pages' PRE function.

Just move the code in your LEAVE function to the next pages' PRE function.

-Stu


Ah - I'm slapping my forehead right now. *slap*

Suddenly I get the whole PRE and LEAVE thing.

It seems to work perfectly like I wanted it to now.

Thanks a lot. :)