Skip to content
⌘ NSIS Forum Archive

un. for FindProcess

1 posts

HughB#

un. for FindProcess

Hi,

I am trying to use FindProcess in an uninstaller function.

I have searched the forum at length and I've gone over threads on how to setup uninstall functions and how to share between install and uninstall sections (e.g.1,2 ) but I am still lost so I've come begging for help or an explanation (please!).

The installer below seems to fail because un.FindProcess does not exist.

Do I need to duplicate FindProcess.nsh and change every function and macro to "un." to make it work or is there an easier way?

Can someone please tell me where I am going wrong?

thanks,

H


!include FindProcess.nsh
Name "test"
OutFile "test.exe"
!macro FindNotepad un
    Function ${un}FindNotepad
        ${FindProcess} "notepad.exe" $0 
        ${If} $0 <> 0
            MessageBox MB_OK "Found notepad"
        ${Else}
            MessageBox MB_OK "no notepad"
        ${EndIf}
    FunctionEnd
!macroend
!insertmacro FindNotepad ""
!insertmacro FindNotepad "un."
;--------------------------------
; Pages
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; The stuff to install
Section "Example (required)"
  SectionIn RO
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  Call FindNotepad
  WriteUninstaller "uninstall.exe"
  
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
  Call un.FindNotepad
     
  Delete $INSTDIR\uninstall.exe
SectionEnd