|
|
|
|
#1 |
|
Junior Member
Join Date: Mar 2006
Posts: 28
|
Hi,
I try to remove a folder and all its contents (RMDir /r). But when i have a open Command Shell which shows the content of the folder which i want to remove i get an error. All files and subfolders will be removed but the folder itself is still there. I made already sure that the SetOutPath points to another folder. I guess the open shell locks the folder which i want to delete and prevent to remove it. Is there a workaround or a way to figure out if a folder is lockend by a process and close that process which is locking it? Thank you for your help. M. |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
This seems to work fine:
code: Explorer window opens showing folder "ja" then closes after 5 seconds when the folder is deleted. -Stu |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2006
Posts: 28
|
Hi Stu,
thank you for your quick answer. I tried out what you suggested but it doesnt work. Sleep 5000 RMDir /r "$INSTDIR" It removes the folder sucessfully when i dont have a shell window showing the content of that folder. But not otherwise, even with the 5 sec delay. M. |
|
|
|
|
|
#4 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
What Windows are you running?
By shell window do you mean Windows Explorer (explorer.exe)? What code are you using to view the folder contents? Try my example in a single Section but use $INSTDIR instead: code: -Stu |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Mar 2006
Posts: 28
|
The shell what i am talking about is the command line shell (cmd.exe). I dont have a problem with the Windows Explorer.
The described behavior only happens with such a command shell. I hopes that helps to understand my problem. M. |
|
|
|
|
|
#6 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Hmm I see now, missed the Command Shell from your first post
![]() Well will Command Prompt always be open? In which way is it viewing the folder... with the dir command or some other executable? I don't know of a way to find out which process last accessed the folder, but that would be your best solution. Otherwise, you could probably close Command Prompt with FindWindow and SendMessage with ${WM_CLOSE}. -Stu |
|
|
|
|
|
#7 |
|
Major Dude
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
|
First of all might be good to understand why console stays open. NSIS distribution includes nsExec plug-in for DOS applications, ExecDos and ExecCmd are available in archive, plug-ins can solve the problem for most of apps (not 100%, test required). From the other side, if user opened console, might be better to leave it as it is (and do not rmdir).
Win9x consoles not accepted windows messages in my tests. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|