Archive: Custom page shows if files doesn't exist


Custom page shows if files doesn't exist
Hi there is there a better way to script this, it seem a bit messy

Basically if the file doesn't exist it shows the custom page warning people it will be installed and run an *.inf file via a *.bat to install these drivers (I say warning as the drivers aren't officially passed by Microsoft, thus the warning not to worry and so on)

if the file does exist the custom page doesn't show and the drivers are not installed


Page custom Mpeg

Function Mpeg
IfFileExists "$SYSDIR\Mpg4dmod.dll.bak" MpegSkip MpegShow
MpegShow:
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "mpeg21.ini"

CreateDirectory "$INSTDIR\Mpeg"
SetFileAttributes "$INSTDIR\Mpeg" HIDDEN
SetOutPath "$INSTDIR\Mpeg"
File "Mpeg\Mpeg.bat"
File "Mpeg\msaud32.acm"
File "Mpeg\MPG4c32.dll"
File "Mpeg\MPG4ds32.ax"
File "Mpeg\msadds32.ax"
File "Mpeg\MS-MPG4.inf"
IfFileExists "$SYSDIR\Mpg4dmod.dll.bak" 0 +2
Delete "$SYSDIR\Mpg4dmod.dll.bak"
IfFileExists "$SYSDIR\Mpg4dmod.dll" 0 +2
Rename "$SYSDIR\Mpg4dmod.dll" "$SYSDIR\Mpg4dmod.dll.bak"
IfFileExists "$SYSDIR\dllcache\Mpg4dmod.dll.bak" 0 +2
Delete "$SYSDIR\dllcache\Mpg4dmod.dll.bak"
IfFileExists "$SYSDIR\dllcache\Mpg4dmod.dll" 0 +2
Rename "$SYSDIR\dllcache\Mpg4dmod.dll" "$SYSDIR\dllcache\Mpg4dmod.dll.bak"
nsExec::Exec '"$INSTDIR\Mpeg\Mpeg.bat"'
SetOutPath "$INSTDIR"
RMDir /r "$INSTDIR\Mpeg"
SetOutPath "$SYSDIR"
File "Mpeg\Mpg4dmod.dll.bak"
MpegSkip:
FunctionEnd


At the moment the files install when you click out of the custom page to go to the install page, but the install page doesn't show until the drivers have finished installing, which is messy

What I would like is this

If file doesn't exist, show custom page but install the drivers with the main installation files

I know how to do this if I where to have it selectable in the components page, you know if it was selected the page would show the files wouldn't be installed and visa versa

but I want to do this so people don't have that option, once the drivers are installed, the page wouldn't show again as its a one off thing

Please help

and thanks

It's dangerous to go alone, take this.


What's that supposed to mean?

You lot are too cryptic, you never give a straight answer


I guess didn't you see that "this" is a link :rolleyes:
and you never play "The legend of link" for NES :rolleyes:


!define CUST_INI "$PLUGINSDIR\custom.ini"
!include sections.nsh

outfile 'test.exe'
InstallDir "$PROGRAMFILES\My Application"
showinstdetails show

page custom CreateCustom
page directory
page instfiles

section main sec1
DetailPrint "Section main: Always install this section"
sectionend

section optional sec2
detailprint "Section optional: Installed when explorer.exe does not exist"
sectionend

Function .onInit
InitPluginsDir
WriteINIStr "${CUST_INI}" "Settings" "NumFields" "1"
WriteINIStr "${CUST_INI}" "field 1" "type" "label"
WriteINIStr "${CUST_INI}" "field 1" "left" "10"
WriteINIStr "${CUST_INI}" "field 1" "right" "-10"
WriteINIStr "${CUST_INI}" "field 1" "top" "10"
WriteINIStr "${CUST_INI}" "field 1" "bottom" "18"
WriteINIStr "${CUST_INI}" "field 1" "text" "hey, i'm a custom (IO) page"
FunctionEnd

Function CreateCustom
IfFileExists "$WINDIR\Explorer.exe" exists notexists
exists:
!insertmacro UnselectSection ${sec2}
abort
notexists:
push $0
InstallOptions::dialog "${CUST_INI}"
pop $0
FunctionEnd

Sorry Joel no I didn't see the link, my eyes aren't what they used to be. :blind > :cool:

And no I never played Legend of Link or Zelda (if those are the same thing or related.

Now I feel stupid with my remark of "What's that supposed to mean?" :(

And Red Wine thank you that makes a lot of sense, thank you again.:D

All I have to do with Section optional is to hide it, then it won't show in the components page, cheers :)

It help when you have a visual bit of script, sorry Joel the script in your link did make a lot sense to me but thanks again.