Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search all exe file in c:\windows

Status
Not open for further replies.

jimshi

Programmer
Aug 26, 2006
6
AU
Hi,
In my c:\windows folder, i have two exe file, they are 1.exe and 2.exe. i want to write a script to search *.exe in folder c:\windows.

after i tried FSO, but failed to do that, help everyone can help me to fix this problem.

Thanks
 
Minor tweaking to Recursive Folder/File Search faq329-5515 leads to:
Code:
strDir = "c:\windows\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objDir = FSO.GetFolder(strDir)
getInfo(objDir)

Sub getInfo(pCurrentDir)

For Each aItem In pCurrentDir.Files 
   If LCase(Right(Cstr(aItem.Name), 3)) = "exe" Then
    'wscript.Echo aItem.Name 'all c:\windows\*.exe listed
   End If
Next


For Each aItem In pCurrentDir.SubFolders
   getInfo(aItem) 'passing recursively
Next

End Sub
 
Hi baltman, thanks very much, it works well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top