VB script for searching a file and delete it
Hi All,
I know the file name to delete, let assume "test.bat" file, but i dont know where exactly it present.
It can be in any drive C, D, E or any.
I have to search for that perticular file and have to delete it from every location wherever it will found.
can anybody gives some about how to write using VB script
I know the file name to delete, let assume "test.bat" file, but i dont know where exactly it present.
It can be in any drive C, D, E or any.
I have to search for that perticular file and have to delete it from every location wherever it will found.
can anybody gives some about how to write using VB script
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
WSPPackager
14 years ago
Posted by:
ditch_nz
14 years ago
Heres basic recursive
strFolder = "C:\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
WScript.Echo objFolder.Path
Set colFiles = objFolder.Files
For Each objFile In colFiles
WScript.Echo objFile.Path
Next
ShowSubFolders(objFolder)
Sub ShowSubFolders(objFolder)
Set colFolders = objFolder.SubFolders
For Each objSubFolder In colFolders
WScript.Echo objSubFolder.Path
Set colFiles = objSubFolder.Files
ShowSubFolders(objSubFolder)
Next
End Sub
strFolder = "C:\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
WScript.Echo objFolder.Path
Set colFiles = objFolder.Files
For Each objFile In colFiles
WScript.Echo objFile.Path
Next
ShowSubFolders(objFolder)
Sub ShowSubFolders(objFolder)
Set colFolders = objFolder.SubFolders
For Each objSubFolder In colFolders
WScript.Echo objSubFolder.Path
Set colFiles = objSubFolder.Files
ShowSubFolders(objSubFolder)
Next
End Sub
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.