1
votes

I have used nsis script for creating installer.When i run my installer second time with same name,REPAIR and REMOVE should be check and do the corresponding operation.I have find out my application already installed or not using following codes,

Function checkinstall
   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My app" "UninstallString" 
   IfFileExists $R0 +1 NotInstalled
   call nsDialogpage
   NotInstalled:
FunctionEnd

Function nsDialogpage
   nsDialogs::Create 1018
    Pop $Dialog
    ${If} $Dialog == error
        Abort
    ${EndIf}
    ${NSD_CreateRadioButton} 0 5u 100% 10u "Repair"
        Pop $hwnd
        ${NSD_AddStyle} $hwnd ${WS_GROUP}
        ${NSD_OnClick} $hwnd ???
    ${NSD_CreateRadioButton} 0 25u 100% 56u "Remove"
        Pop $hwnd
        ${NSD_OnClick} $hwnd ???
    nsDialogs::Show

If the user select repair button it should overwrites existing installation path else uninstall existing installed and continue with new one.what am i need do to replace the (???) of the above code

page custom checkinstall
!insertmacro MUI_PAGE_DIRECTORY

My next page is Directory selection.so i need to call this page? How to achieve this?

1.How can i call un installer function if the user selects remove button?

   Function un.Init, section /o -un.Main UNSEC000,section -un.post UNSE001

these are the un installer funtions.How can i call these functions? i have tried call method but it did not work.

1

1 Answers

1
votes

You need to specify a callback function, like in the nsDialogs documentation, look for the nsDialogsPageLeave function in this example:

!include nsDialogs.nsh
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Var Dialog
Var Label
Var Text

Page custom nsDialogsPage nsDialogsPageLeave
Page instfiles

Function nsDialogsPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
    Pop $Label

    ${NSD_CreateText} 0 13u 100% -13u "Type something here..."
    Pop $Text
    ${NSD_OnChange} $Text nsDialogsPageTextChange

    nsDialogs::Show

FunctionEnd

Function nsDialogsPageLeave

    ${NSD_GetText} $Text $0
    MessageBox MB_OK "You typed:$\n$\n$0"

FunctionEnd

Function nsDialogsPageTextChange
    Pop $1 # $1 == $ Text
    ${NSD_GetText} $Text $0
    ${If} $0 == "hello"
        MessageBox MB_OK "right back at ya!"
    ${EndIf}
FunctionEnd

Section
    DetailPrint "hello world"
SectionEnd