PDA

View Full Version : Removing Locked Directories on Uninstall



nexus6
03-24-2006, 10:47 AM
During the uninstallation sequence, I have tried various ways to remove a directory and its subdirs; all methods fail because some files in the directory are locked -- the reason being, the uninstaller is running from there (so its files and the _jvm subdir files are locked).

This is what I've tried:
1) just let IS do it automatically - files go away, but not the main directory
2) remove dirs/files with FileService methods in a custom event bean - fails due to locking
3) used Java itself (oh no!) to remove the dirs/files via File.delete() - fails due to locking
4) used Java itself with File.deleteOnExit() - fails to due locking

The goal here is to remove the whole directory tree (and its parent if it is empty) for where the installer puts its files (and uninstaller).

Any help would be appreciated - I don't want empty directories left behind.

Thanks!

nexus6
03-24-2006, 10:49 AM
oh yeah; when I use the FileService, it forces the uninstall to prompt the user to reboot (not required before) to complete the install - not good. However, even after rebooting, those directories still remain!

Thanks!

smunya
05-18-2006, 06:49 AM
Hi,

did you figured it out?
I have the same problem.

Thank you

nexus6
05-18-2006, 08:36 AM
I did not figure it out so much as I was forced to do a "work around" where I kicked off a batch file (and did not "wait" for it to complete/return) at the end of the install that "slept" for a few seconds and then used the rmidr DOS command to remove the directory structure. It worked because the uninstaller was no longer running (locking the dir) by the time that the rmdir command was executed. Ugly, but effective.

I tried so many other things!!!

Good luck.

wpeterson
05-19-2006, 11:15 AM
You could also use JNI code to manually schedule the directory for deletion on reboot via the MoveFileEx Win32 api call (MSDN Link (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/movefileex.asp).) Note: This means setting a move to destination NULL with the MOVEFILE_DELAY_UNTIL_REBOOT flag set.