Archive: Finish Page Option Fails To Execute


Finish Page Option Fails To Execute
I have a finish page with three options:

1) Create Desktop shortcut
2) Create Quick Launch shortcut
3) Launch MyApp

If option #2 is de-selected then the last option, #3, doesn't execute. I'm at a loss to figure out why. Can someone point in proper direct here? This is my script:

;NSIS Modern User Interface
;Welcome/Finish Page Example Script
;Written by Joost Verburg

;--------------------------------
;Include Modern UI

!include "MUI.nsh"

SetCompressor BZIP2

;--------------------------------
;General

;Name and file
Name "My App"
OutFile "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\NSIS\myapp.exe"
XPStyle on
RequestExecutionLevel admin

!define MUI_ICON "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\NSIS\tgd.ico"
!define MUI_UNICON "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\NSIS\tgd.ico"

;Default installation folder
InstallDir "$PROGRAMFILES\My App"

;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\My App" ""

VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "My App"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Inventory, backup, restore and locate system drivers."
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "MyCompany Corp."
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "My App is a trademark of MyCompany Corp."
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© MyCompany Corp. 2003 - 2008"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Inventory, backup, restore and locate system drivers."
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.1.29"

VIProductVersion "2.1.29.0"


;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING

;--------------------------------
;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\NSIS\Install Path\License.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
;!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

;--------------------------------
;Modified Finish Page

!define MUI_PAGE_CUSTOMFUNCTION_PRE fin_pre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW fin_show
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE fin_leave

!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION Desc_ShortCut
!define MUI_FINISHPAGE_RUN_TEXT "Create Desktop Shortcut"
!insertmacro MUI_PAGE_FINISH

;!insertmacro MUI_UNPAGE_WELCOME
;!insertmacro MUI_UNPAGE_CONFIRM
;!insertmacro MUI_UNPAGE_INSTFILES
;!insertmacro MUI_UNPAGE_FINISH

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------

;Installer Functions

Function Desc_Shortcut
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\My App.lnk" "$INSTDIR\myprog2.exe"
FunctionEnd

Function fin_show

;--------------------------------
;Create Start Menu Program Files Shortcut

CreateDirectory "$SMPROGRAMS\My App"
CreateShortcut "$SMPROGRAMS\My App\My App.lnk" "$INSTDIR\myprog2.exe"
CreateShortCut "$SMPROGRAMS\My App\My App Home Page.lnk" "http://www.mycoolprog.com/" "URL" "" "" "" "" "My App Home Page"

ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "HWND"
SetCtlColors $0 0x000000 0xFFFFFF
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "HWND"
SetCtlColors $0 0x000000 0xFFFFFF
FunctionEnd

Function fin_pre
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "6"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Text" "&Create Quicklaunch Shortcut"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Right" "315"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Top" "110"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Bottom" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "State" "1"

WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "7"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Text" "&Launch My App"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Right" "315"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Top" "130"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Bottom" "140"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "State" "1"

FunctionEnd

Function fin_leave

ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "State"
StrCmp $0 "0" end
SetOutPath "$INSTDIR"
CreateShortCut "$QUICKLAUNCH\My App.lnk" "$INSTDIR\myprog2.exe"

ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "State"
StrCmp $0 "0" end
SetOutPath "$INSTDIR"
Exec "$INSTDIR\myprog2.exe"



end:
FunctionEnd

;--------------------------------
;Installer Sections

Section "Dummy Section" SecDummy

SetOutPath "$INSTDIR"

;ADD YOUR OWN FILES HERE...

File "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\myprog2.exe"

File "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\Help\drvgdtk2.chm"

File "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\NSIS\Install Path\*.*"

SetOutPath "$INSTDIR\bin"

File "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\NSIS\bin\*.*"

SetOutPath "$SYSDIR"
SetOverwrite try

File "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\NSIS\System Path\*.*"

SetOutPath "$SYSDIR\wbem"
SetOverwrite off

File "\\MyServer\C\MyCompany\Projects\MyCompany Corp\TGD Projects\Premium\TGD\NSIS\wbem\*.*"

;Store installation folder
WriteRegStr HKCU "Software\My App" "" $INSTDIR

;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"

RegDLL "$INSTDIR\bin\Codejock.CommandBars.v10.4.0.ocx"
RegDLL "$INSTDIR\bin\Codejock.DockingPane.v10.4.0.ocx"
RegDLL "$INSTDIR\bin\Codejock.PropertyGrid.v10.4.0.ocx"
RegDLL "$INSTDIR\bin\Codejock.ReportControl.v10.4.0.ocx"
RegDLL "$INSTDIR\bin\Codejock.TaskPanel.v10.4.0.ocx"

RegDLL "$SYSDIR\MSCOMCTL.OCX"
RegDLL "$SYSDIR\msvbvm60.dll"
RegDLL "$SYSDIR\scrrun.dll"
RegDLL "$SYSDIR\shfolder.dll"

WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "DisplayName" "My App"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "DisplayIcon" "$INSTDIR\myprog2.exe,0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "DisplayVersion" "2.1.29"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "URLInfoAbout" "http://www.mycoolprog.com/"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "HelpLink" "http://www.mycoolprog.com/"

WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "NoModify" "1"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App" "NoRepair" "1"

SectionEnd

;--------------------------------
;Descriptions

;Language strings
;LangString DESC_SecDummy ${LANG_ENGLISH} "A test section."

;Assign language strings to sections
;!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
;!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
;!insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------
;Uninstaller Section

Section "Uninstall"

;ADD YOUR OWN FILES HERE...

;ExecWait 'regsvr32.exe /u /s "$INSTDIR\bin\Codejock.CommandBars.v10.4.0.ocx"'
;ExecWait 'regsvr32.exe /u /s "$INSTDIR\bin\Codejock.DockingPane.v10.4.0.ocx"'
;ExecWait 'regsvr32.exe /u /s "$INSTDIR\bin\Codejock.PropertyGrid.v10.4.0.ocx"'
;ExecWait 'regsvr32.exe /u /s "$INSTDIR\bin\Codejock.ReportControl.v10.4.0.ocx"'
;ExecWait 'regsvr32.exe /u /s "$INSTDIR\bin\Codejock.TaskPanel.v10.4.0.ocx"'

RMDir /r /REBOOTOK "$INSTDIR"
RMDir /r "$SMPROGRAMS\My App"

Delete "$DESKTOP\My App.lnk"
Delete "$QUICKLAUNCH\My App.lnk"

DeleteRegKey HKCU "Software\My App"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\My App"

Delete "$INSTDIR\Uninstall.exe"

SectionEnd


Function fin_leave

ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "State"
StrCmp $0 "0" next
SetOutPath "$INSTDIR"
CreateShortCut "$QUICKLAUNCH\My App.lnk" "$INSTDIR\myprog2.exe"

next:
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "State"
StrCmp $0 "0" end
SetOutPath "$INSTDIR"
Exec "$INSTDIR\myprog2.exe"

end:
FunctionEnd


Just of curiosity...
May I ask why you're creating Start Menu shortcuts within show function of finish page?

I moved it there because I found that it to would fail to execute if I left it in the place I did have it:

Function fin_leave
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "State"
StrCmp $0 "0" end
SetOutPath "$INSTDIR"
CreateShortCut "$QUICKLAUNCH\My App.lnk" "$INSTDIR\myprog2.exe"

ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "State"
StrCmp $0 "0" end
SetOutPath "$INSTDIR"
Exec "$INSTDIR\myprog2.exe"

;--------------------------------
;Create Start Menu Program Files Shortcut

CreateDirectory "$SMPROGRAMS\My App"
CreateShortcut "$SMPROGRAMS\My App\My App.lnk" "$INSTDIR\myprog2.exe"
CreateShortCut "$SMPROGRAMS\My App\My App Home Page.lnk" "http://www.mycoolprog.com/" "URL" "" "" "" "" "My App Home Page"

end:
FunctionEnd

Based on your reply I'm guessing all I need to do is add that "Next:" statement and I'm all set.

Thanks!


Well, I tried adding the next statement per your suggestion and the last option still would not execute when I de-selected option #2. I also noticed that when I compiled the script it indicated something about label "next" option not being used.

I have it changed just as you show it in your post. Am I missing something here?


I didn't show in my post that the Start Menu icons should go into the leave function, where did you see that?

I've just noticed that you're missing a label hence the function does not work as you expect.

You may go with logiclib to make things easier:

Function fin_leave

ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "State"

${If} $0 = 1
SetOutPath "$INSTDIR"
CreateShortCut "$QUICKLAUNCH\My App.lnk" "$INSTDIR\myprog2.exe"
${EndIf}

ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "State"

${If} $0 = 1
SetOutPath "$INSTDIR"
Exec "$INSTDIR\myprog2.exe"
${EndIf}

FunctionEnd

I wasn't implying that you showed the Start Menu icons as being in the leave function. I'm the one that put the code there. Right now, that isn't the issue.

The failure for option #3 to work if option #2 is de-selected still doesn't work after changing the code to what you show in your last post. Do I need to include something else? What is "logiclib"? Is that something I need to add to make things work? My code now looks just like what you show but it still fails. I don't understand why the next bit of code doesn't process if option #2 is de-selected. It just skips it.

Boneyhead


Got it now. Changed to this and it now works like a charm:

Function fin_leave


ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "State"

StrCmp $0 "0" next
SetOutPath "$INSTDIR"
CreateShortCut "$QUICKLAUNCH\My App.lnk" "$INSTDIR\myprog2.exe"

next:

ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "State"
StrCmp $0 "0" end
SetOutPath "$INSTDIR"
Exec "$INSTDIR\myprog2.exe"

end:
FunctionEnd


That's exactly what I've posted firstly.

Allow me to say that you're using nsis (which is an absolute fair choice), however, you haven't spend some time to review the documentation and to learn what's included.