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-24 04:07
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Delete thumbnail temporary files → VBS version View 1,327 Replies 3
Original Poster Posted 2007-03-18 06:49 ·  中国 河北 保定 联通
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
Originally intended to delete Thumbs.db files generated by the thumbnail viewing method, but modified to allow manually entering the name to search and delete specified files such as virus derivatives_desktop.ini

Note:
Right-clicking on a file performs a search in the current directory and its subdirectories.
Right-clicking on a folder performs a search in the target directory and its subdirectories.

http://zhenlove.com.cn/cndos/fileup/files/Del_Thumbs.rar


Floor 2 Posted 2007-03-18 07:13 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
```vb
Dim WshSHell, FSO, keyWord, DirTotal, TimeSpend, FileTotal, delFile, txtResult, txtPath
On Error Resume Next
Set WshSHell = WScript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.Filesystemobject")
Set WinVer = WshSHell.Environment("Process")
Set Args = WScript.Arguments
CloseTime = 5
FileName = WScript.ScriptName
FileFullName = WScript.ScriptFullName
FilePath = FSO.GetParentFolderName(FileFullName)
InsPath = FSO.GetSpecialFolder(1)
InsFullName = FSO.BuildPath(InsPath, FileName)
LnkPathNT = WshSHell.SpecialFolders(2)
LnkPath9X = WshSHell.SpecialFolders(14)
LnkPathAll = WshSHell.SpecialFolders("StartMenu")
OtherFileName = "Thumbs.db"
OtherFilePath = FSO.GetSpecialFolder(1)
TemFileName = "PathCopyEx.reg"
TemFilePath = FSO.GetSpecialFolder(1)
Copyright = "玲珑科技"
QQ = "QQ:25926183"
Email = "Email:fty1995@163.com"
InsTitle = "删除缩略图临时文件"
InsAnswer = "删除缩略图临时文件"
RegPath1 = "HKEY_CLASSES_ROOT\Directory\shell\Del_Thumbs\"
RegValue1 = "删除缩略图临时文件"
RegForm1 = "REG_SZ"
RegPath2 = "HKEY_CLASSES_ROOT\Directory\shell\Del_Thumbs\command\"
RegValue2 = "wscript.exe " & Chr(34) & InsFullName & Chr(34) & " " & Chr(34) & "%L" & Chr(34)
RegForm2 = "REG_SZ"
RegPath3 = "HKEY_CLASSES_ROOT\*\shell\Del_Thumbs\"
RegPath4 = "HKEY_CLASSES_ROOT\*\shell\Del_Thumbs\command\"
If FileFullName <> InsFullName Then
intAnswer = MsgBox("【是】将“" + InsAnswer + "”加入到右键菜单," & Chr(10) & Chr(10) & "【否】将“" + InsAnswer + "”从右键菜单删除。 ", vbQuestion + vbYesNoCancel, "安装 - " + InsTitle + " - " + Copyright)
If intAnswer = vbYes Then
WshSHell.RegWrite RegPath1, RegValue1, RegForm1
WshSHell.RegWrite RegPath2, RegValue2, RegForm2
WshSHell.RegWrite RegPath3, RegValue1, RegForm1
WshSHell.RegWrite RegPath4, RegValue2, RegForm2
FSO.GetFile(FileFullName).Copy(InsFullName)
WshShell.popup "添加脚本文件:" + Chr(10) + InsFullName + Chr(10) + Chr(10) + "添加注册表项:" + Chr(10) + Chr(34) + RegPath3 + Chr(34) + Chr(10) + Chr(34) + RegPath1 + Chr(34) + Chr(10) + Chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" + Chr(10) + Chr(10) + Chr(10) & "Copyright(C) " + Copyright + " " & QQ & " " + Email, CloseTime, "安装成功 - " + InsTitle + " - " + Copyright, 0 + 64
End If
If intAnswer = vbNo Then
WshSHell.RegDelete RegPath4
WshSHell.RegDelete RegPath3
WshSHell.RegDelete RegPath2
WshSHell.RegDelete RegPath1
FSO.DeleteFile InsFullName
WshShell.popup "删除脚本文件:" + Chr(10) + InsFullName + Chr(10) + Chr(10) + "删除注册表项:" + Chr(10) + Chr(34) + RegPath3 + Chr(34) + Chr(10) + Chr(34) + RegPath1 + Chr(34) + Chr(10) + Chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" + Chr(10) + Chr(10) + Chr(10) & "Copyright(C) " + Copyright + " " & QQ & " " + Email, CloseTime, "卸载成功 - " + InsTitle + " - " + Copyright, 0 + 64
End If
If intAnswer = vbCancel Then
End If
Else
If Args.count = "0" Then: WScript.Quit(0): End If
FileTotal = 0
DirTotal = 0
If FSO.GetFile(Args(0)).attributes And 16 Then
txtPath = Trim(Args(0))
Else
txtPath = Trim(FSO.GetParentFolderName(Args(0)))
End If
'keyWord = LCase(OtherFileName)
keyWord = LCase(InputBox("请输入欲删文件名:", "文件删除", "Thumbs.db"))
If keyWord = "" Then WScript.Quit(0)
TimeSpend = Timer
myFind txtPath
TimeSpend = Round(Timer - TimeSpend, 2)
txtResult = "搜索完成!(用时:" & TimeSpend & "秒.)" & vbCrLf & vbCrLf & "共搜索目录:" & DirTotal & "个." & vbCrLf & "删除Thumbs:" & FileTotal & "个."
WshShell.popup Chr(10) & txtResult & Chr(10) + Chr(10) + Chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" + Chr(10) + Chr(10) + Chr(10) & "Copyright(C) " + Copyright + " " & QQ & " " + Email, CloseTime, "删除" & OtherFileName & "文件 - " + InsTitle + " - " + Copyright, 0 + 64
End If
Set WshSHell = Nothing
Set FSO = Nothing
Set Args = Nothing
WScript.Quit(0)
Sub myFind(ByVal thePath)
Dim fso, myFolder, myFile, curFolder
Set FSO = CreateObject("Scripting.Filesystemobject")
Set curFolders = fso.getfolder(thePath)
DirTotal = DirTotal + 1
If curFolders.Files.Count > 0 Then
For Each myFile In curFolders.Files
If InStr(1, LCase(myFile.Name), keyWord) > 0 Then
If FSO.GetFile(FormatPath(thePath) & "\" & myFile.Name).attributes And 1 Then
FSO.GetFile(FormatPath(thePath) & "\" & myFile.Name).attributes = FSO.GetFile(FormatPath(thePath) & "\" & myFile.Name).attributes - 1
End If
FSO.DeleteFile FormatPath(thePath) & "\" & myFile.Name
FileTotal = FileTotal + 1
End If
Next
End If
If curFolders.subfolders.Count > 0 Then
For Each myFolder In curFolders.subfolders
myFind FormatPath(thePath) & "\" & myFolder.Name
Next
End If
End Sub
Function FormatPath(ByVal thePath)
thePath = Trim(thePath)
FormatPath = thePath
If Right(thePath, 1) = "\" Then FormatPath = Mid(thePath, 1, Len(thePath) - 1)
End Function
```
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
jmz573515 +8 2007-03-18 08:38
baomaboy +2 2007-03-18 10:00
Floor 3 Posted 2007-03-18 12:43 ·  中国 四川 成都 联通
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
I always feel the code is a bit complicated... But it's still good, thumbs up

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 4 Posted 2007-04-16 09:50 ·  中国 湖北 潜江 电信
高级用户
★★★
Credits 894
Posts 411
Joined 2007-02-17 12:15
19-year member
UID 79697
Gender Male
Status Offline
Thumbs.db is originally a thumbnail file, no wonder there is one in each picture folder, so that's how it is.
@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


Forum Jump: