Archive: Check for the existance of directories?


Check for the existance of directories?
Im very new to NSIS but I love it. Its a better solution for me then the commercial solutions I researched. I have one question though. I plan on installing multiple things into a series of folders over time. Something like this:

/program files/company name/app1
/program files/company name/app2
/program files/company name/app3

When someone uninstalls on of these applications, I want to know if it was the last item in the /company name/ folder so I can delete that folder as well? The ultimate goal is that I want the uninstall to clean up everything thats left over and unnecessary. I was wondering if there are easy ways to handle this? Thanks!

Michael


Hi Michael,

take a look at makensis.nsi in your installdir of NSIS. Use this:

RMDir /r "$PROGRAMFILES\company name\app3"
IfFileExists "$PROGRAMFILES\company name\app3" 0 Continue
MessageBox MB_OK "App3 still present!"
Continue:

If the dir will not be removed, than files are still present in the dir.

Good luck, greetz, Hn3.


Hi Michael,

you could use Hn3's code to check whether your app folder was deleted properly.

To check whether it was the last app in your companies folder you could use this code:

RMDir /r "$PROGRAMFILES\company name\app3"
RMDir "$PROGRAMFILES\company name"
IfFileExists "$PROGRAMFILES\company name" 0 Removed
MessageBox MB_OK "Company Name folder not empty"
Removed:
SectionEnd
The call to 'RMDir "$PROGRAMFILES\company name"' only deletes this folder when it's empty.

Hope this helps -
Regards,
~ Florian