Tạo chức năng tìm kiếm bằng Vbscript ?

Tạo chức năng tìm kiếm bằng Vbscript ??
vu manh tuan
vu manh tuan
Trả lời 16 năm trước
Thật là “điên đầu” khi bạn lục tung cả kho tàng tài liệu Microsoft Word trên hệ điều hành của bạn . Làm thế nào ta có thể tìm tập tin .doc , .exe , .bat , … dể dàng mà không phụ thuộc chức năng tìm kiếm của Windows XP . Dim objFSO Dim ofolder Dim objStream Set objFSO = CreateObject("scripting.filesystemobject") ' Tao mot tap tin .log co ten la Search de xuat ra Set objStream = objFSO.createtextfile("e:\search.log", True) CheckFolder (objFSO.getfolder("e:\")), objStream MsgBox "Qua trinh kiem tra da xong !!!" + vbCr + "Ban kiem tra tap tin E:\Search.log de xem ket qua tim kiem" _ + vbCr + "Please contact with me :”_ + vbCr + "www.ktxonline.net ; " Sub CheckFolder(objCurrentFolder, objLogFile) Dim strTemp Dim strSearch Dim strOutput Dim objNewFolder Dim objFile Dim objStream strSearch = ".doc" For Each objFile In objCurrentFolder.Files strTemp = Right(objFile.Name, 4) If UCase(strTemp) = UCase(strSearch) Then 'Got one strOutput = CStr(objFile.Name) + "," + CStr(objFile.Path) + "," + CStr(objFile.Size) + "," _ + CStr(objFile.Type) + "," + CStr(objFile.datelastaccessed) objLogFile.writeline strOutput End If Next For Each objNewFolder In objCurrentFolder.subFolders CheckFolder objNewFolder, objLogFile Next End Sub Bạn lưu tập tin này lại là timkiem.vbs Lưu Ý : Ở dòng CheckFolder (objFSO.getfolder("e:\")), objStream bạn có thể thay đổi thành c:\ để tìm kiếm ổ đĩa C : Ởdòng strSearch = ".doc" bạn có thể thay đổi bằng strSearch = ".exe" để tìm các tập tin .exe Công việc tiếp theo bạn chạy tập tin timkiem.vbs , sau đó nó sẽ xuất hiện bãng thông báo (như hình dưới) đến đây bạn chỉ việc mở vào E:\search.log để xem các tập tin này .