Skip to content
⌘ NSIS Forum Archive

uninstaller problems

8 posts

BigBadBurrows#

uninstaller problems

Hi all,

I recently added a function to my installer to allow the user to select between a minimum database which is 200Mb or an extended database which is 900Mb. Before I always installed the extended one.

To do this I created an options file to allow the user to chose which database to install: -


;Read a value from an InstallOptions INI file
ReadINIStr $R0 "$PLUGINSDIR\database.ini" "Field 2" "State"


; Test to see which Database is to be installed
StrCmp $R0 "1" "" Extended


DetailPrint "Installing Minimum Database"
setOutPath "$INSTDIR\data\english"
File /r "C:\mindata\english\*.*" ; contains the minimal distributed tables

setOutPath "$INSTDIR\data\usa"
File /r "C:\mindata\usa\*.*" ; contains the minimal distributed tables

Goto Done


Extended:


DetailPrint "Installing Extended Database"
SetOutPath "$INSTDIR\data\english"
File /r "C:\fulldata\english\*.*" ; contains the extended tables

SetOutPath "$INSTDIR\data\usa"
File /r "C:\fulldata\usa\*.*"


Done:
This bit works ok. And it installs the database I select.

As part of the installation I also create an uninstaller: -


Section "Uninstall"

RMDir "$INSTDIR\j2re"
RMDir "$INSTDIR\Program Files"
RMDir "INSTDIR\data\english"
RMDir "INSTDIR\data\usa"

Delete "$INSTDIR\Uninstall.exe"

SectionEnd
However, when I run the installer program when it gets to the stage where the uninstaller is created, it pauses for a few minutes then I get an error "Error creating uninstall.exe"

When I try and run the uninstaller all it does is delete the Uninstall.exe, but non of the other files.

I never had this problem before I added the ability to chose the database, so i'm guessing that might have something to do with it.

Does anyone know why this might be happening?

Many Thanks,

Martin

P.S. I'm using NSIS 2.01
Yathosho#
hopefully the solution is simple as that: you used INSTDIR instead of $INSTDIR in the uninstaller section.. but i guess you would've gotten an error while compiling the installer, dunno
Yathosho#
you could use IfFileExists and MessageBox to make sure the uninstaller finds the files you intend to delete
BigBadBurrows#
OK, I tried using a message box to display the paths to be deleted. The path is correct but the directory still isn't being deleted. The only thing I can think of that there isn't a closing slash, e.g.

"C:\Program Files\MyApp\Program Files"

Am I also using the right method to delete the folder?

RMDir "$INSTDIR\Program Files"

Any ideas? I'm baffled
Takhir#
Are you sure that folders are empty? To remove not empty folder use

RMDir /r "$INSTDIR"

instead of 5 lines in your Uninstall section. This is little dangerous because user can copy Uninstaller to root folder and run it with default $INSTDIR = c:\ 🙁 , but this works.
BigBadBurrows#
FIXED!!

Thanks Yathosho & Takhir. It was what Takhir suggested, and the folder werent empty so they weren't being deleted. The /r flag fixed it though

Thanks again