Posts

Showing posts from May, 2006

Windows Script to search for a file in all the drives

Script below will search for a file in all drives(excluding network mapped drive) 'filename to search for filename="test.txt" On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk",,48) For Each objItem in colItems Set fs = CreateObject("Scripting.FileSystemObject") Set folder = fs.GetFolder(objItem.Caption) fList(folder) Next sub fList(folderObj) for each file in folderObj.Files if file.name=filename then Wscript.Echo "File found at" & file.Path exit for end if next for each folder in folderObj.subfolders fList(folder) next end sub