VBScript and WMI Need to delete Folder/Files under the parent directory How to?
Posted on 2006-06-28
I need to delete files and folders under a directory but keep the base. I have tried FSO Example
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.DeleteFolder "D:\test\*", True
FSO.DeleteFile "D:\test\*", True
But if a file/directory is open or can not be removed the script stops and ends. From what I can tell I will have to use WMI in the script and enumerate. I am a total newbie!! and dont have a clue. What I want to do is
1) Delete all files and subdirectories under \\<sharename>\TEST\ but not TEST itself
2) If a file or folder is open and locked skip that file/folder and continue (FSO can NOT do this)
3) Pass a error level back.
If someone can give me a working example it really would be great!!!!