Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
I have written an application whose uninstaller eventually calls a .BAT file to help uninstall itself, as well as delete the directory the uninstall.exe was sitting in. For some reason, my rmdir command is failing to delete the directory. See code below:
:Repeat
del "C:\Program Files\MM\Uninstall.exe"
if exist "C:\Program Files\MM\Uninstall.exe" goto Repeat
rmdir "C:\Program Files\MM"
del "C:\fiUninst.bat";Everything else is working, including the line right after rmdir. What could be preventing my script from deleting that folder? After uninstall.exe is successfully deleted, there's nothing left in the folder, so it can't be a straggler file that is preventing deletion. And the 'if exist' loop should guarantee that, by the time the batch file gets to the rmdir line, uninstall.exe is already gone.
-Tony

First, make sure you are not currently using the directory that you are trying to remove.
Then, try this line, instead of the one you are using now...
rmdir /S /Q "C:\Program Files\MM"
IR

Hi,
Okay: "not currently using" does not include having it open in Windows explorer, right? Because i know i can delete a folder in a DOS window and have an open explorer window disappear on deletion. But the user DOES have to double-click on the Uninstaller.exe in the MM folder in order to begin the uninstall process. So could it be that, even though my fiUninst.bat script is the one issuing the rmdir command, that command still does not work because the user just clicked on Uninstall.exe a few seconds ago and the MM window still HAS FOCUS?
-Tony

Well, I have ruled out that it has anything to do with the explorer window being open or having the focus, as I have tried Uninstall from the DOS command line with no window open and it still fails to delete MM. Now that does not mean that windows does not like that I am in the folder in the first place. But it does rule out some things.
I am currently pursuing the idea that the Uninstall.exe is still in the stack while the .bat is running, thereby preventing Windows from deleting the folder.
-Tony

Okay, here's the official scoop:
"
C:\Program Files\MegaMeeting>rmdir "C:\Program Files\MegaMeeting"The process cannot access the file because it is being used by another process.
"So there you have it. For some reason, even though my Uninstall.exe has finished running, Windows still thinks the folder is actively being used. Now how do i convince it otherwise?
-tony

FORGET IT - I found the problem. After I delete Uninstall.exe, I am still in the Program Files/MM folder!! So being in that folder obviously prevents me from deleting it later in my .BAT file.
-Tony

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |