Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to find the file with specified extension in hard disk partition by vbs

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "vbs how to find the specified extension file in the hard disk partition", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "vbs how to find the specified extension file in the hard disk partition" this article.

The code is as follows:

On Error Resume Next 'ignore all errors

Dim filename 'declares variables

Dim re

Set re=New RegExp 'create a regular expression object instance

Re.Pattern= "^ ([amerz] | [Amurz]) +\:\ w+\ .vbs $"

If re.Test (WScript.ScriptFullName) = False Then

MsgBox "Please run this program under the root of the disk, otherwise the search results may be incorrect!" , "MessageBox"

WScript.Quit

End If

Re.Pattern= "^ ([A-Za-z0-9 _] | [^\ X00 -\ xff]) +\. [a-zA-Z] {1pc4} $" 'declares the matching pattern of regular expressions, which is mainly used to verify whether the file name entered by the user is correct.

Do

Filename=InputBox ("Please enter the file name you want to search for:", "MessageBox")

If filename= "" Then WScript.Quit 'exit the script if the input is empty

If re.Test (filename) = False Then

MsgBox "Please enter a valid file name!" , "MessageBox"

End If

Loop While re.Test (filename) = False 'does not jump out of the loop until the user enters the correct file name.

Set re=Nothing

Dim ie

Set ie=WScript.CreateObject ("internetexplorer.application") 'creates an IE object to display the search status

Ie.menubar=0 'does not display the IE object menu bar

Ie.AddressBar=0 'does not display the IE object address bar

Ie.ToolBar=0 'does not display the IE object toolbar

Ie.StatusBar=0 'does not display the IE object status bar

Ie.FullScreen=1 'full screen IE object

Ie.Width=640 'sets the width of the IE object

Ie.Height=120 'sets the height of IE object

Ie.Resizable=0 'sets whether the IE object size can be changed

Ie.Navigate "about:blank" sets the page that the IE object points to by default

Ie.Left=Fix ((ie.Document.parentwindow.screen.availwidth-ie.Width) / 2) 'sets the left margin of the IE object

Ie.top=Fix ((ie.document.parentwindow.screen.availheight-ie.height) / 2) 'sets the right margin of the IE object

Ie.visible=1 'sets whether the IE object is visible

With ie.Document'is written to the page in the IE object, which is no different from the normal HTML

.write ""

.write ""

.write "File scan status"

.write ""

.write ""

.write ""

.write ""

.write ""

.write "starting the search program."

.write ""

.write "0 Then

Ie.Document.getElementById ("header") [xss_clean] = "found" & I & "match. The details have been saved in the" & result & "file."

Else

Ie.Document.getElementById ("header") [xss_clean] = "File search is in progress."

End If

WScript.Sleep (20)

Next

Set objsubfolders=objfolder.SubFolders' gets a collection of all folders under the current path

For Each objsubfolder In objsubfolders' traverses folders

Nowpath=path & "\" & objsubfolder.Name 'get the new file path

Search nowpath 'calls the function itself and starts searching from the new path

Next

End Function

Set fso=CreateObject ("scripting.filesystemobject")

Set objdrives=fso.Drives' gets all the disk drives of the current computer

For Each objdrive In objdrives' traverses the disk

Search objdrive 'call function

Next

'The information displayed at the end

Ie.Document.getElementById ("header") [xss_clean] = "scan is over."

If I > 0 Then

Ie.Document.getElementById ("middle") [xss_clean] = "Please open" & result & "" for detailed search results! "

Else

Ie.Document.getElementById ("middle") [xss_clean] = "No files found to search!"

End If

'destroy object variables to free memory space

Set objdrives=Nothing

Set objfiles=Nothing

Set objfile=Nothing

Set objdrive=Nothing

Set objfolders=Nothing

Set objfolder=Nothing

Set objsubfolders=Nothing

Set objsubfolder=Nothing

Set fso=Nothing

The above is all the contents of the article "how to find the specified extension file in the hard disk partition by vbs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report