China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 06:49
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » No technical depth at all — using FSO to analyze which EXEs a user has used recently View 2,131 Replies 9
Original Poster Posted 2006-12-25 12:19 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
It has comments, so there's no need to explain it, right? This is mainly for newbies learning FSO. Actually, when you have a shell, analyzing what programs the user has accessed recently and which programs they use most often is still quite helpful.


'Automatically call cscript to start the script
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("Folder to analyze:",WScript.ScriptName,"D:\"))
Set oOutTxt=FSO.CreateTextFile("Recently accessed exe.txt",1)
EnumFolders(oFolder)
oOutTxt.Close

'Procedure for traversing folders, recursive
Sub EnumFolders(oTargetFolder)
For Each oSubFolder In oTargetFolder.SubFolders
'WScript.Echo oSubFolder
MostRecentExeFile(oSubFolder)
EnumFolders(oSubFolder)
Next
End Sub

'Procedure for getting the most recently accessed 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 'Prevent the case of folders that contain no exe
If (p<0.1 And MostRecentExe<>"") Then 'Conditions: 1. exe files account for less than 10% of all files. Some folders are just green portable tools, and getting only one result out of them is meaningless. It's more interesting to analyze folders like Office. 2. Prevent cases where some folders contain no exe
WScript.Echo MostRecentExe
oOutTxt.WriteLine MostRecentExe & Chr(9) & CDate(MostRecent)
End If

End Sub

Floor 2 Posted 2006-12-25 21:44 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Super bump~~~
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 3 Posted 2006-12-25 21:54 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
I'll bump it too~ :)
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 4 Posted 2006-12-25 22:06 ·  中国 广东 肇庆 四会市 电信
中级用户
★★
Credits 384
Posts 189
Joined 2005-10-19 13:12
20-year member
UID 43709
Gender Male
Status Offline
I'll come help bump it too, hey-yo hehe...

Brother, your VBS is really good, learned quite a lot more stuff again... hehe...
Floor 5 Posted 2007-02-11 22:28 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Good stuff
Floor 6 Posted 2007-02-11 22:32 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Bumping this, but I can't understand it
Floor 7 Posted 2007-05-07 19:11 ·  中国 广东 中山 电信
初级用户
★★
Credits 127
Posts 62
Joined 2007-04-19 12:43
19-year member
UID 85744
Gender Male
Status Offline
Learning
Floor 8 Posted 2007-05-07 19:20 ·  中国 北京 利达宽带
中级用户
★★
Credits 273
Posts 91
Joined 2007-05-07 18:12
19-year member
UID 87770
Gender Male
Status Offline
C:\test.vbs(28, 1) Microsoft VBScript runtime error: Permission denied
Floor 9 Posted 2007-05-07 20:41 ·  中国 湖北 武汉 武昌区 电信
中级用户
★★
scriptlover
Credits 328
Posts 131
Joined 2007-03-25 22:17
19-year member
UID 82910
Gender Male
Status Offline
Learning from the OP, and learning VBS well.
scriptlover
Be with script forever!!
Floor 10 Posted 2008-03-23 23:28 ·  中国 广东 广州 电信
中级用户
★★
Credits 233
Posts 117
Joined 2007-11-28 02:38
18-year member
UID 104005
Gender Male
Status Offline
I don't understand VBS at all. Need to learn from the OP
Forum Jump: