I need to delete the folder from which a script was called. So far I can
delete the contents (including the script) but not the actual folder. Note
the folder is open and the script is ran from the open folder.

RE: Delete folder script ran from? by akiuni

akiuni
Tue Jan 24 09:46:03 CST 2006

Hi

I think that's just impossible... You can't delete a folder opened just
because there is a lock on it. Try to rename it, if it can't, so you should
not be able to delete it...




--
akiuni



"Yogi_Bear_79" wrote:

> I need to delete the folder from which a script was called. So far I can
> delete the contents (including the script) but not the actual folder. Note
> the folder is open and the script is ran from the open folder.
>
>
>

Re: Delete folder script ran from? by Michael

Michael
Tue Jan 24 18:52:08 CST 2006

akiuni wrote:
> Hi
>
> I think that's just impossible... You can't delete a folder opened
> just because there is a lock on it. Try to rename it, if it can't, so
> you should not be able to delete it...


Simple test to prove your point. The *contents* of the folder (including the
executing script) will be deleted by the folder itself will not (even with
no open explorer/cmd window opened for it.

Create an empty folder and create a script (name doesn't matter) in the
folder with the following code and then run it...

set fso = createobject("scripting.filesystemobject")
set myFolder = fso.getfolder(wscript.scriptfullname & "\..")
msgbox myFolder.path & " has files: " & myFolder.files.count
on error resume next
myFolder.delete
msgbox err.description
on error goto 0
msgbox myFolder.path & " has files: " & myFolder.files.count



--
Michael Harris
Microsoft MVP Scripting