/build/static/layout/Breadcrumb_cap_w.png

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

0 Comments   [ + ] Show comments

Answers (2)

Posted by: WSPPackager 13 years ago
Senior Purple Belt
0
Prepare the recursive function to search an file...this is very basic programming skill that you need...
Posted by: ditch_nz 13 years ago
Purple Belt
0
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ