Good start.
Here is a method, with the search part included.
Code:
Break ON
$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")
Dim $sPath, $fdFileList, $sFileList
Dim $sSearchPattern
; *** Change the search pattern to the name of the file you want to find ***
$sSearchPattern="C:\rmt.exe"
$sFileList=%TEMP%+"\FileList.txt"
; Create output list
Shell '"'+%COMSPEC%+'" /C DIR /B/S "'+$sSearchPattern+'" >> "'+$sFileList+'"'
If @ERROR "COULD NOT CREATE FILE LIST: "+@ERROR+" "+@SERROR+@CRLF Exit @ERROR EndIf
; Open file list for reading
$fdFileList=FreeFileHandle()
If Open($fdFileList,$sFileList) "COULD NOT OPEN FILE LIST FOR READING: "+@ERROR+" "+@SERROR+@CRLF Exit @ERROR EndIf
; Iterate entries
$sPath=ReadLine($fdFileList)
While Not @ERROR
$sPath=Left($sPath,InStrRev($sPath,"\")-1)
"Now deleting directory "+$sPath+@CRLF
; *** Do your delete stuff here ***
$sPath=ReadLine($fdFileList)
Loop
$=Close($fdFileList)
Exit 0