Ron.Stordahl
12th August 2011 17:37 UTC
Varying the MUI2 Pages based on OS Version
I want to be able to present a different series of install screens to the user depending upon that OS the install is executing upon, for example Vista/Windows 7 and higher vs XP and lower.
Within sections I am currently using the test:
${If} ${AtLeast_OS} ; Previously defined as AtLeastWinVista
--- do this--
${Else}
--- do this instead--
${Endif}
successfully within sections, however such tests are not valid outside of installer Sections or Functions and all my MUI2 definitions proceed the first Installer Section.
The OS version is of course dynamically determined at run time, thus it would seem that such tests would have to be in a section, but I do not see where the MUI2 runtime actions are actually called.
How do I do this?
Anders
12th August 2011 20:33 UTC
insertmacro MUI_PAGE_WELCOME
>!define MUI_PAGE_CUSTOMFUNCTION_PRE canpage_nt6
>!insertmacro MUI_PAGE_COMPONENTS
>!define MUI_PAGE_CUSTOMFUNCTION_PRE canpage_win4
>!insertmacro MUI_PAGE_DIRECTORY
>!insertmacro MUI_PAGE_INSTFILES
>!insertmacro MUI_LANGUAGE "English"
>Function canpage_nt6
>${If} ${AtLeast ....
Abort
>${EndIf}
>FunctionEnd
>Function canpage_win4
>${If} ${AtMost ....
Abort
>${EndIf}
>FunctionEnd
>
Ron.Stordahl
14th August 2011 15:52 UTC
Thanks Anders for your comment...I was unaware of this capability.
Where would I place the call to the functions in your example to insure that they will be called before any page is displayed (and thus too late)?
LoRd_MuldeR
14th August 2011 16:03 UTC
You have to define them as PRE-page functions, as in Anders' example. You don't call them explicitly!
Make sure you have a "!define MUI_PAGE_CUSTOMFUNCTION_PRE <func_name>" right before the corresponding "!insertmacro MUI_PAGE_FOOBAR" - for all pages that should (not) be shown based on some condition.
If the PRE-page function associated with a certain page calls "Abort", then that page won't be shown. Of course you can associate several pages with the same PRE-page function, if these pages should (not) be shown based on the same condition.
Ron.Stordahl
15th August 2011 22:20 UTC
I am having success with controlling the pages with the help received, but I get an error when using these lines:
!define MUI_PAGE_CUSTOMFUNCTION_PRE AtLeast_OS_or_Later_A
!define MUI_DIRECTORYPAGE_TEXT_TOP "Application Data Files associated with BPQ32 and its selected optional components, will be installed \
or updated in the Destination Folder selected below.$\r$\n$\n\
Click Install to continue the process or cancel to quit."
!define MUI_DIRECTORYPAGE_VARIABLE $APPDATA
!insertmacro MUI_PAGE_DIRECTORY
The error is with the MUI_DIRECTORYPAGE_VARIABLE. If I enter $INSTDIR all is well, but as shown with $APPDATA I get this error:
Error: cannot change constants : $APPDATA
Usage: DirVar $(user_var: dir in/out))
What I want the page to offer is the expansion of %appdata%\BPQ32, which would expand for example to:
c:\Users\'username'\AppData\Roaming\BPQ32
How can I accomplish this?
Anders
15th August 2011 23:44 UTC
You need to create your own variable, then StrCpy $YourVar $APPDATA before you get to the page
Ron.Stordahl
16th August 2011 17:17 UTC
Thanks Anders. I have the custom pages working with your help. Here is a snippet of how it was done:
define MUI_PAGE_CUSTOMFUNCTION_PRE AtLeast_OS_or_Later_A
>!define MUI_DIRECTORYPAGE_TEXT_TOP "Application Data Files associated with BPQ32 and its selected optional components, will be installed \
or updated in the Destination Folder selected below.$\r$\n$\n\
Click Install to start the process or cancel to quit."
>!define MUI_DIRECTORYPAGE_VARIABLE $ApplicationDataPath
>!insertmacro MUI_PAGE_DIRECTORY
>.
.
Function AtLeast_OS_or_Later_A
>${If} ${AtLeast_OS}
StrCpy $ApplicationDataPath $APPDATA${PRODUCT_NAME}
${Else}
Abort
>${EndIf}
>FunctionEnd
>
In my original installer both the programs and the application data went into %programfiles%. Now when the test ${AtLeast_OS} is satisfied, currently set to Vista, I
place application data at %appdata%\"program name".
Anders
16th August 2011 17:29 UTC
This AtLeast_OS thing only makes sense if you are testing for Win9x, all NT systems have the same problem, you are just not testing as non-admin!