cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
nexus6
Level 3

Removing Locked Directories on Uninstall

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!
Labels (1)
0 Kudos
(4) Replies
nexus6
Level 3

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!
0 Kudos
smunya
Level 2

Hi,

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

Thank you
0 Kudos
nexus6
Level 3

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.
0 Kudos
wpeterson
Level 3

You could also use JNI code to manually schedule the directory for deletion on reboot via the MoveFileEx Win32 api call (MSDN Link.) Note: This means setting a move to destination NULL with the MOVEFILE_DELAY_UNTIL_REBOOT flag set.
0 Kudos