当前位置:DOS资源站资料中心VBS脚本 → 分析用户最近使用了哪些exe

分析用户最近使用了哪些exe

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-6-1 20:15:03

'自动调用 cscript 来启动脚本
set oSh=CreateObject("WScript.Shell")
If lcase(right(WScript.FullName,11))="wscript.exe" Then
        oSh.Run "cmd /ccscript //NoLogo //e:vbscript " & WScript.ScriptFullName
        WScript.Quit
End If

Set FSO = CreateObject("Scripting.FileSystemObject")

Set oFolder = FSO.GetFolder(Inputbox("要分析的文件夹:",WScript.ScriptName,"D:\"))
Set oOutTxt=FSO.CreateTextFile("最近访问的exe.txt",1)
EnumFolders(oFolder)
oOutTxt.Close

'遍历文件夹的过程,递归
Sub EnumFolders(oTargetFolder)
For Each oSubFolder In oTargetFolder.SubFolders
        'WScript.Echo oSubFolder
        MostRecentExeFile(oSubFolder)
        EnumFolders(oSubFolder)
Next
End Sub

'获得最近访问的exe的过程。
Sub MostRecentExeFile(oTargetFolder)
Dim a,i,MostRecent,MostRecentExe

For Each oFile In oTargetFolder.Files
        If Right(oFile.Name,3)="exe" Then
                i=i+1
                CurrIndex=CurrIndex+1
                If CCur(oFile.DateLastAccessed) > MostRecent Then
                        MostRecent=CCur(oFile.DateLastAccessed)
                        MostRecentExe=oFile
                End If
        End If
        a=a+1
Next
If i> 0 Then p=i/a        '防止没有包含exe的文件夹的情况
If (p<0.1 And MostRecentExe<>"") Then        '条件:1. exe文件占所有文件的10%以下。有的文件夹是绿色小软件,只分析出来一个没有意思。要分析想Office那样的文件夹猜有意思2. 防止有的文件夹不包含exe
        WScript.Echo MostRecentExe
        oOutTxt.WriteLine MostRecentExe & Chr(9) & CDate(MostRecent)
End If

End Sub