Skip to content
⌘ NSIS Forum Archive

Uninstaller

2 posts

badcom#

Uninstaller

Hi guys,

I'm struggling to uninstall a program. The problem is that it won't delete the file Uninstall.exe neither the install folder.

Here's my code:


;function for check previous version
Function CheckPreviousVersion

Call KillRunning

ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" \
"UninstallString"
StrCmp $R0 "" done

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${PRODUCT} is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort

;Run the uninstaller
uninst:
ClearErrors
ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file

IfErrors no_remove_uninstaller
;You can either use Delete /REBOOTOK in the uninstaller or add some code
;here to remove the uninstaller. Use a registry key to check
;whether the user has chosen to uninstall. If you are using an uninstaller
;components page, make sure all sections are uninstalled.
no_remove_uninstaller:

done:

FunctionEnd

; ===============================================================================================
; == *** UN-INSTALLER *** ==
; ===============================================================================================
Section "Uninstall"
call un.KillRunning ; close any already running

# Always delete uninstaller first
Delete $INSTDIR\Uninstall.exe

;Delete Start Menu Shortcuts
;alter to be wildcard - we do not know how many the user chose to install
Delete "$DESKTOP\Emod Firefox *.lnk"
;Delete "$DESKTOP\Emod Chrome *.lnk"

;Delete Files & directory
RMDir /r "$INSTDIR"

;Delete Uninstaller And Unistall Registry Entries
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${PRODUCT}"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
Any suggestion?

Thanks in advance!
Anders#
Does it only happen when you are using _?= with ExecWait or is normal uninstall also broken?

Can you try Process Monitor and see why the delete fails?