|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
『楼 主』:
求一个用vbs查找硬盘所有分区中的11.exe程序?
使用 LLM 解释/回答一下
求一个用vbs查找硬盘所有分区中的11.exe程序?
最好能注释
Please provide the specific Chinese content that needs to be translated. Currently, the text you provided is in Chinese but not fully clear. Please clarify the complete text that needs translation.
|
|
2007-2-11 06:18 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
|
2007-2-11 11:54 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
建议dir /s /b 分区:\*.exe
然后vbs读取这个全部文件路径的文本
看每行的后5个字符是不是11.exe
Last edited by slore on 2007-2-11 at 02:12 PM ]
Suggest using dir /s /b partition:\*.exe
Then have a VBS read the text file containing all the file paths. Check if the last 5 characters of each line are 11.exe
Last edited by slore on 2007-2-11 at 02:12 PM ]
|
|
2007-2-11 12:36 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
我主要是想学习vbs,实现这个功能的用法?
其实
原本就是学习
楼上的兄弟,能不能写出全部的代码?
文本读取,用vbs,正是我现在想要学习的
I mainly want to learn VBS and how to use it to achieve this function? Actually, it was originally for learning. Brother above, can you write out the entire code? Text reading using VBS is exactly what I want to learn now
|
|
2007-2-11 22:27 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
|
2007-2-12 02:39 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
我一边对照命令介绍一边看
加深理解,但理解不足呀?
I read while referring to the command introduction to deepen my understanding, but my understanding is still insufficient.
|
|
2007-2-12 06:11 |
|
|
kich
中级用户
  
积分 397
发帖 168
注册 2006-10-8
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
是想查多少个,还是查具体路径呢?
新手先问一下
Are you going to check how many or the specific path?
Newcomer asks first
|
|
2007-2-12 11:53 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
|
2007-2-12 11:56 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
不管是不是新手,能回复都感谢!!!
因为我在问,你在答!!
No matter whether you are a novice or not, I appreciate any response!!! Because I am asking and you are answering!
|
|
2007-2-12 11:57 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
BAT文件:
@echo off
dir /s /b C\*.exe>Allexe.txt
:可以在家别的盘用>>追加
cscript vbsfile.vbs
type 11.exe.txt
pause>nul
VBSFile.vbs文件:
Const ForReading = 1
Const ForWriting = 2
Set objFSO = Createobject("Scripting.Filesystemobject")
Set objFile = objFSO.OpenTextFile("allexe.txt", ForReading)
Set OutFile = objFSO.OpenTextFile("11.exe.txt", ForWriting,True)
Dim num
num=0
Do While objFile.AtEndOfStream<>True
strText = objFile.Readline
If Mid(Instrrev(strText,"\")+1,5)="11.exe" Then
Msgbox strText
num=num+1
OutFile.Writeline strText
End If
Loop
OutFile.Writeline " 总共发现" & num & "个11.exe文件"
OutFile.Close
objFile.Close
Batch file:
@echo off
dir /s /b C\*.exe>Allexe.txt
:Can be used in other disks at home>>Append
cscript vbsfile.vbs
type 11.exe.txt
pause>nul
VBSFile.vbs file:
Const ForReading = 1
Const ForWriting = 2
Set objFSO = Createobject("Scripting.Filesystemobject")
Set objFile = objFSO.OpenTextFile("allexe.txt", ForReading)
Set OutFile = objFSO.OpenTextFile("11.exe.txt", ForWriting,True)
Dim num
num=0
Do While objFile.AtEndOfStream<>True
strText = objFile.Readline
If Mid(Instrrev(strText,"\")+1,5)="11.exe" Then
Msgbox strText
num=num+1
OutFile.Writeline strText
End If
Loop
OutFile.Writeline " Total found " & num & " 11.exe files"
OutFile.Close
objFile.Close
|
|
2007-2-12 14:07 |
|
|
112183883
初级用户
 
积分 128
发帖 31
注册 2006-10-23
状态 离线
|
  『第 11 楼』:
使用 LLM 解释/回答一下
偶也写了一个,可搜索所有分区,代码如下,保存为任意.vbs文件双击便可,如果嫌麻烦的朋友可以下载附件。(注意请在磁盘根目录下运行)。
On Error Resume Next '忽略所有错误
Dim filename '声明变量
Dim re
Set re=New RegExp '建立正则表达式对象实例
re.Pattern="^(|)+\:\\\w+\.vbs$"
If re.Test(WScript.ScriptFullName)=False Then
MsgBox "请在磁盘根目录下运行本程序,否则搜索结果可能会不正确!",,"MessageBox"
WScript.Quit
End If
'声明正则表达式的匹配模式,主要用来检验用户输入的文件名是否正确
re.Pattern="^(|)+\.{1,4}$"
Do
filename=InputBox("请输入你要搜索的文件名:","MessageBox")
If filename="" Then WScript.Quit '如果输入为空则退出脚本
If re.Test(filename)=False Then
MsgBox "请输入合法的文件名!",,"MessageBox"
End If
Loop While re.Test(filename)=False '直到用户输入正确的文件名时才跳出循环。
Set re=Nothing
'建立IE对象,用来显示搜索状态
Dim ie
Set ie=WScript.CreateObject("internetexplorer.application")
ie.menubar=0 '不显示IE对象菜单栏
ie.AddressBar=0 '不显示IE对象地址栏
ie.ToolBar=0 '不显示IE对象工具栏
ie.StatusBar=0 '不显示IE对象状态栏
ie.FullScreen=1 '全屏化IE对象
ie.Width=640 '设置IE对象宽度
ie.Height=120 '设置IE对象高度
ie.Resizable=0 '设置IE对象大小是否可以被改动
ie.Navigate "about:blank" '设置IE对象默认指向的页面
'设置IE对象左边距
ie.Left=Fix((ie.Document.parentwindow.screen.availwidth-ie.Width)/2)
'设置IE对象右边距
ie.top=Fix((ie.document.parentwindow.screen.availheight-ie.height)/2)
ie.visible=1 '设置IE对象是否可视
'以下为在IE对象中写入页面,跟一般的HTML没有区别
With ie.Document
.write "<html>"
.write "<head>"
.write "<title>文件扫描状态</title>"
.write "<meta http-equiv=""content-type"" content=""text/html;charset=gb2312"">"
.write "<style><!--"
.write "body { background:#000000;text-align:center;margin:0px auto; }"
.write "* { font-family:Arial;font-size:9pt;color:#00cc00;line-height:140%; }"
.write "a:link,ahover,a:visited { text-decoration:none; }"
.write "#scanstatus { text-align:left;margin:15px; }"
.write "#header { width:100%;height:20px; }"
.write "#middle { width:100%;height:50px; }"
.write "#footer { width:100%;height:20px;text-align:right; }"
.write "--></style>"
.write "</head>"
.write "<body scroll=no>"
.write "<div id=""scanstatus"">"
.write "<div id=""header"">正在启动搜索程序。。。</div>"
.write "<div id=""middle""></div>"
.write "<div id=""footer""><a href=""#"" onclick=""window.close()"">退出程序</a></div>"
.write "</div>"
.write "</body>"
.write "</html>"
End With
'定义文件系统对象变量
Dim fso
Dim objfolder
Dim objsubfolders
Dim objsubfolder
Dim objfiles
Dim objfile
Dim objdrives
Dim objdrive
Dim objtextfile
Dim str:str=""
Dim i:i=0 '计数器变量
Dim result
result="C:\搜索结果.html" '搜索结果保存文件变量
'用来遍历硬盘文件的函数
Function search(path)
Set objfolder=fso.getfolder(path) '获得当前路径
Set objfiles=objfolder.Files '获得当前路径下的所有文件集合
For Each objfile In objfiles '开始遍历文件集合
'将当前搜索的文件路径写入ID为middle的DIV中
ie.Document.getElementById("middle").innerHTML=objfile.Path
'如果当前文件名与用户输入的文件名一致
If objfile.Name=filename Then
i=i+1 '计数器加一
str=str & objfile.Path & "<br>"
'创建文本流对象,文件名为变量result所存储的字符串
Set objtextfile=fso.OpenTextFile(result,2,True)
'将变量str中的文件路径写入html文件中
objtextfile.Write(str)
objtextfile.Close '关闭文本流对象
Set objtextfile=Nothing '销毁对象
End If
If i>0 Then
ie.Document.getElementById("header").innerHTML="找到 " & i & " 个匹配,详细信息已保存在 """ & result & """ 文件中。。。"
Else
ie.Document.getElementById("header").innerHTML="正在执行文件搜索。。。"
End If
WScript.Sleep(20)
Next
Set objsubfolders=objfolder.SubFolders '得到当前路径下的所有文件夹的集合
For Each objsubfolder In objsubfolders '遍历文件夹
nowpath=path & "\" & objsubfolder.Name '得到新的文件路径
search nowpath '调用函数自身,从新的路径开始搜索
Next
End Function
Set fso=CreateObject("scripting.filesystemobject")
Set objdrives=fso.Drives '取得当前计算机的所有磁盘驱动器
For Each objdrive In objdrives '遍历磁盘
search objdrive '调用函数
Next
'结束时显示的信息
ie.Document.getElementById("header").innerHTML="扫描已结束。。。"
If i>0 Then
ie.Document.getElementById("middle").innerHTML="请打开 """ & result & """ 查看详细搜索结果!"
Else
ie.Document.getElementById("middle").innerHTML="没有找到要搜索的文件!"
End If
'销毁对象变量,释放内存空间
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
顺便还加了注释,不过现在还有一点问题就是有的目录还没搜索就跳过去了,不知道是权限问题还是啥原因。
Last edited by 112183883 on 2007-2-12 at 07:11 PM ]
I also wrote one that can search all partitions. The code is as follows. Save it as any.vbs file and double-click it. Friends who find it troublesome can download the attachment. (Note: Please run it in the root directory of the disk.)
On Error Resume Next 'Ignore all errors
Dim filename 'Declare variable
Dim re
Set re=New RegExp 'Create an instance of the regular expression object
re.Pattern="^(|)+\:\\\w+\.vbs$"
If re.Test(WScript.ScriptFullName)=False Then
MsgBox "Please run this program in the root directory of the disk, otherwise the search results may be incorrect!",,"MessageBox"
WScript.Quit
End If
'Declare the matching pattern of the regular expression, mainly used to check whether the file name entered by the user is correct
re.Pattern="^(|)+\.{1,4}$"
Do
filename=InputBox("Please enter the file name you want to search for:","MessageBox")
If filename="" Then WScript.Quit 'If the input is empty, exit the script
If re.Test(filename)=False Then
MsgBox "Please enter a legal file name!",,"MessageBox"
End If
Loop While re.Test(filename)=False 'Jump out of the loop until the user enters the correct file name.
Set re=Nothing
'Create an IE object to display the search status
Dim ie
Set ie=WScript.CreateObject("internetexplorer.application")
ie.menubar=0 'Do not display the menu bar of the IE object
ie.AddressBar=0 'Do not display the address bar of the IE object
ie.ToolBar=0 'Do not display the toolbar of the IE object
ie.StatusBar=0 'Do not display the status bar of the IE object
ie.FullScreen=1 'Make the IE object full screen
ie.Width=640 'Set the width of the IE object
ie.Height=120 'Set the height of the IE object
ie.Resizable=0 'Set whether the size of the IE object can be changed
ie.Navigate "about:blank" 'Set the default page pointed to by the IE object
'Set the left margin of the IE object
ie.Left=Fix((ie.Document.parentwindow.screen.availwidth-ie.Width)/2)
'Set the right margin of the IE object
ie.top=Fix((ie.document.parentwindow.screen.availheight-ie.height)/2)
ie.visible=1 'Set whether the IE object is visible
'Write to the page in the IE object below, which is no different from general HTML
With ie.Document
.write "<html>"
.write "<head>"
.write "<title>File scanning status</title>"
.write "<meta http-equiv=""content-type"" content=""text/html;charset=gb2312"">"
.write "<style><!--"
.write "body { background:#000000;text-align:center;margin:0px auto; }"
.write "* { font-family:Arial;font-size:9pt;color:#00cc00;line-height:140%; }"
.write "a:link,ahover,a:visited { text-decoration:none; }"
.write "#scanstatus { text-align:left;margin:15px; }"
.write "#header { width:100%;height:20px; }"
.write "#middle { width:100%;height:50px; }"
.write "#footer { width:100%;height:20px;text-align:right; }"
.write "--></style>"
.write "</head>"
.write "<body scroll=no>"
.write "<div id=""scanstatus"">"
.write "<div id=""header"">Starting the search program...</div>"
.write "<div id=""middle""></div>"
.write "<div id=""footer""><a href=""#"" onclick=""window.close()"">Exit program</a></div>"
.write "</div>"
.write "</body>"
.write "</html>"
End With
'Define the file system object variable
Dim fso
Dim objfolder
Dim objsubfolders
Dim objsubfolder
Dim objfiles
Dim objfile
Dim objdrives
Dim objdrive
Dim objtextfile
Dim str:str=""
Dim i:i=0 'Counter variable
Dim result
result="C:\Search Results.html" 'Search result save file variable
'Function to traverse hard disk files
Function search(path)
Set objfolder=fso.getfolder(path) 'Get the current path
Set objfiles=objfolder.Files 'Get the collection of all files in the current path
For Each objfile In objfiles 'Start traversing the file collection
'Write the current searched file path into the DIV with ID middle
ie.Document.getElementById("middle").innerHTML=objfile.Path
'If the current file name is consistent with the file name entered by the user
If objfile.Name=filename Then
i=i+1 'Counter plus one
str=str & objfile.Path & "<br>"
'Create a text stream object, the file name is the string stored in variable result
Set objtextfile=fso.OpenTextFile(result,2,True)
'Write the file path in variable str into the html file
objtextfile.Write(str)
objtextfile.Close 'Close the text stream object
Set objtextfile=Nothing 'Destroy the object
End If
If i>0 Then
ie.Document.getElementById("header").innerHTML="Found " & i & " matches, and the detailed information has been saved in the """ & result & """ file..."
Else
ie.Document.getElementById("header").innerHTML="Performing file search..."
End If
WScript.Sleep(20)
Next
Set objsubfolders=objfolder.SubFolders 'Get the collection of all folders in the current path
For Each objsubfolder In objsubfolders 'Traverse the folders
nowpath=path & "\" & objsubfolder.Name 'Get the new file path
search nowpath 'Call the function itself, start searching from the new path
Next
End Function
Set fso=CreateObject("scripting.filesystemobject")
Set objdrives=fso.Drives 'Get all disk drives of the current computer
For Each objdrive In objdrives 'Traverse the disks
search objdrive 'Call the function
Next
'Information displayed at the end
ie.Document.getElementById("header").innerHTML="Scanning completed..."
If i>0 Then
ie.Document.getElementById("middle").innerHTML="Please open """ & result & """ to view the detailed search results!"
Else
ie.Document.getElementById("middle").innerHTML="No file to search found!"
End If
'Destroy object variables and release 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
By the way, comments are also added. But there is still a problem now that some directories are skipped before searching. I don't know if it's a permission issue or something.
Last edited by 112183883 on 2007-2-12 at 07:11 PM ]
附件
1: Fsearch.rar (2007-2-12 19:12, 2.26 KiB, 下载附件所需积分 1 点
,下载次数: 44)
|
|
2007-2-12 17:57 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
这个vbs脚本好难看懂
里面为什么涉及到网页了??
This VBS script is really hard to understand. Why does it involve web pages inside?
|
|
2007-2-12 21:25 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
|
2007-2-13 04:50 |
|
|
112183883
初级用户
 
积分 128
发帖 31
注册 2006-10-23
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
IE对象只是用来写界面而已
Last edited by 112183883 on 2007-2-13 at 09:39 AM ]
The IE object is just used for writing the interface and so on.
Last edited by 112183883 on 2007-2-13 at 09:39 AM ]
|
|
2007-2-13 09:36 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
运行了一下,确实漂亮
It runs, and it's really beautiful.
|
|
2007-2-13 10:30 |
|