madden
30th December 2009 15:59 UTC
How to delete files with /REBOOTOK and then remove the directory if empty ?
Hello
In my uninstaller I have to remove the installed application from a program group (under my company). That is for all of:
- directory and files
- start menu shortcuts and groups
- registry keys
That is my files live in
$PROGRAMFILES\Company\Program Group\Program Name\
the registry keys live in
HKCU\Software\Company\Program Group\Program Name\
and the Start Menu Shortcuts live in
$SMPROGRAMS\Company\Program Group\Program Name\
Now if after I remove my application the program group is left emtpy I want to also delete the program group directory.
If after that the compnay directory (in Program Files) is left emtpy I want to delete that too.
Problem is I delete files with /REBOOTOK flag so files might be still present even after my Delete instruction. How can I then check if the directory would be left emtpy after reboot, so I can RMDir /REBOOTOK ?
Thank you,
Timothy Madden
Joel
31st December 2009 19:12 UTC
Well, If I was making that installer, I would do the following
1.- Uninstaller adds a Registry entry @ RunOnce
2.- Use a tool that would uses this.
3.- You can also check again RmDir, you can remove the folder if is empty.
LoRd_MuldeR
1st January 2010 18:47 UTC
madden, look here:
http://nsis.sourceforge.net/Recursiv...nt_directories
madden
4th January 2010 16:16 UTC
I know how to check for emtpy directories and remove them as long as files are not in use. When files are in use and can not be deleted until reboot then the directory is now longer empty, although after reboot it will be !
How would I put my uninstaller in RunOnce ? What if the user postpones the reboot and immediately re-installs the application ? Then after the reboot the app would be deleted by my RunOnce key !
Thank you,
Timothy Madden
LoRd_MuldeR
4th January 2010 16:40 UTC
Maybe you can avoid having to use /REBOOTOK with something like this:
http://nsis.sourceforge.net/LockedList_plug-in
It's better to avoid that situation instead of inventing workarounds ;)
Anyway: If the installer is registered in RunOnce to clean-up the folders after reboot, it still would only delete empty directories, right? Assuming that /REBOOTOK delted files are removed during the boot process before RunOnce applications are started. So if the user did re-install application between uninstall and reboot, nothing bad would happen...
Or even uglier: Let your installer remove a pending clean-up from RunOnce, if present :D
madden
4th January 2010 18:04 UTC
Excelent plug-in!
Thank you.
Looking for something like this I used KillProc to check if my executable is running while installing/uninstalling and killing it myself. But of course this would solve only most part of the problem and not all. LockedList is indeed the solution to my /REBOOTOK problem, but I still have the feeling it is possible to run into some system file that can not be so easily installed without /REBOOTOK ...
Thank you,
Timothy Madden