dilbertz
28th February 2007 07:40 UTC
removing the installed folder when uninstalling
Greetings
I'm trying to fight with the problem of removeing the installed folder where I placed uninstall.exe.
I thought of uninstalling from a higher folder than the installed.
In order to do that I wrote a small function:
Function un.OnInit
${un.GetParent} "$INSTDIR" $R0
CpyStr $INSTDIR $R0
MessageBox MB_OK '"$OUTDIR" will be uninstalled from "$INSTDIR"'
FunctionEnd
and $INSTDIR is replaced by $OUTDIR throughout the Uninstall Section.
And it worked.
But if the MessageBox is neutralized, replaced by DetailPrint, moved to the Uninstall Section - it does not work.
Everything is uninstalled except the folder.
Why?
Thanks in advance
Dilbertz
Red Wine
28th February 2007 07:52 UTC
Just place the uninstaller into $INSTDIR, e.g.
WriteUninstaller "$INSTDIR\uninstall.exe"
don't forget to add at the end of uninstall section, after you've deleted all files/folders individual, the command RmDir "$INSTDIR".
Also, you may want to have a look at Advanced Uninstall Log,
http://nsis.sourceforge.net/Advanced...og_NSIS_Header
dilbertz
28th February 2007 08:09 UTC
Thanks for your lightening fast answer.
Of course I did both
WriteInstaller $INSTDIR\Uninstaller.exe in the install section
and RMDir /r $INSTDIR in the Uninstall section
and it didn't work! i.e. everything was deleted except $INSTDIR itself
Unless you meant: in addition to RMDir /r $INSTDIR
the last line should be RMDir $INSTDIR
I'll try.
Thanks again.
Dilbertz
Red Wine
28th February 2007 08:13 UTC
no i'd never suggest RMDir /r
all files deleted and remains $INSTDIR empty?
dilbertz
28th February 2007 08:18 UTC
Sorry but I have subfolders in $INSTDIR and apart from registry handling that's all I do.
And you're right all files and subfolders deleted and I stayed with empty $INSTDIR but I haven't tried RMDir $INSTDIR yet. You're too fast, man.
Thanks
Red Wine
28th February 2007 09:46 UTC
When all files/folders removed, adding RMDir "$INSTDIR" should remove parent if it's empty.
I'm going to do a guess, what about a hidden file e.g. help.GID which remains invisible?
Takhir
28th February 2007 11:35 UTC
This happen if dir is 'working' for instaler (or other program). Add SetOutPath "$WINDIR" before folder deletion.