Archive: Uninstall Problem


Uninstall Problem
I'm having the same problem as:

This Dude

When my uninstall runs, it gets rid of the registry entries and the uninstall file itself, but not the files or directory. I'm not entirely positive I'm doing it right (I created these files originally with NSIS Workbench and have modified them from there. Here's the basic gist:

;NSIS Script For Centre Web

;Backgound Colors
BGGradient 800080 000000 FFFFFF
BrandingText " "

;Title Of Your Application
Name "MyApp"

;Do A CRC Check
CRCCheck On

;Output File Name
OutFile "Install.exe"

;The Default Installation Directory
InstallDir "$PROGRAMFILES\MyApp"

;The text to prompt the user to enter a directory
DirText "Please select the folder below"

Section "Install"
;Install Files
SetOutPath $INSTDIR
SetCompress Auto
SetOverwrite IfNewer
File /r "D:\MyStageDir\*.*"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "DisplayName" "MyApp (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "UninstallString" "$INSTDIR\Uninst.exe"
WriteUninstaller "Uninst.exe"
SectionEnd

Section "Shortcuts"
;Add Shortcuts
SectionEnd

UninstallText "This will uninstall MyApp from your system"

Section Uninstall
;Delete Files
Delete "$INSTDIR\*.*"

;Delete Uninstaller And Unistall Registry Entries
Delete "$INSTDIR\Uninst.exe"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\MyApp"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MyApp"
RMDir "$INSTDIR"
SectionEnd

;--------------------------------
;Installer Functions

Function .onInit

ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "UninstallString"
StrCmp $R0 "" done

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"MyApp 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


done:

FunctionEnd


Actually my problem is a bit simpler than his. The delete isn't recursive. The command:

Delete "$INSTDIR\*.*"

Only gets the files directly under $INSTDIR and when it does the:

RMDir "$INSTDIR"

It fails because there are files and directories underneath. Any help?

Thanks


If you wish to remove $INSTDIR and all of its contents, then use:

RMDir /r "$INSTDIR"


Doesn't seem to be working afro-dude. I just changed the uninstall section line from

RMDir "$INSTDIR"

to

RMDir /r "$INSTDIR"

The $INSTDIR doesn't go away and a lot of folders and files stick around underneath that. Any clue?


Maybe the $INSTDIR is not correct here, you have to detect it in the Uninstall Functions or Sections. The value of $INSTDIR variable in installation, is not detected automatically in Uninstall! [EDIT] To detect it, try reading the installation string in registry or INI files.


Are you sure these files are not in use? Can you delete them manually?