当前位置: 首页 > 图文教程 > 脚本技术 > VBScript > 清除垃圾的VBS文件 自动查找多个盘

VBScript
VBS教程:正则表达式简介 -定位符
VBS教程:正则表达式简介 -限定符
VBS教程:正则表达式简介 -字符匹配
VBS教程:正则表达式简介 -非打印字符
VBS教程:正则表达式简介 -特殊字符
VBS教程:正则表达式简介 -普通字符
VBS教程:正则表达式简介 -优先权顺序
VBS教程:正则表达式简介 -建立正则表达式
VBS教程:正则表达式简介 -正则表达式语法
VBS教程:正则表达式简介 -使用正则表达式
VBS教程:正则表达式简介 -早期起源
VBS教程:正则表达式简介 -正则表达式
VBS教程:正则表达式简介
VBS教程:属性-VolumeName 属性
VBS教程:属性-Type 属性
VBS教程:属性-TotalSize 属性
VBS教程:属性-SubFolders 属性
VBS教程:属性-Size 属性
VBS教程:属性-ShortPath 属性
VBS教程:属性-ShortName 属性

VBScript 中的 清除垃圾的VBS文件 自动查找多个盘


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 109 ::
收藏到网摘: n/a

复制代码 代码如下:

rem made by correy
rem made at 2007.9.22
rem it can be delete you computer's the follow things(except cd,dvd)
rem it can be delete empty file and folder
rem it can be delete .tmp ._mp .log .gid .chk .old file
rem it can be delete temp,recent,cookis,recycled,prefetch,and "Temporary Internet Files" folder.
rem i am thinking how to delete the same size and same name's file and folder
On Error GoTo 0
Set fso = CreateObject("Scripting"&"."&"FileSystem"&"Object")
for n = 1 to 3
For Each d in fso.Drives
if d.drivetype=4 then
Exit For
else
scan(d)
end if
next
next
sub scan(folder)
on error resume next
set folder=fso.getfolder(folder)
for each file in folder.files
if file.size=0 then
file.delete(true)
end if
ext=fso.GetExtensionName(file)
ext=lcase(ext)
if ext="tmp" or ext="_mp" or ext="log" or ext="gid" or ext="chk" or ext="old" then ''30
file.delete(true)
end if
next
for each subfolder in folder.subfolders
rem instrRev() can't be used,i want to find "\".
if left(subfolder.path,4)="temp" or left(subfolder.path,8)="recycled" then
subfolder.delete(true)
elseif left(subfolder.path,6)="recent" or left(subfolder.path,7)="cookis" then
subfolder.delete(true) rem 40
elseif left(subfolder.path,24)="Temporary Internet Files" or left(subfolder.path,8)="prefetch" then
subfolder.delete(true)
end if
if subfolder.size=0 then subfolder.delete(true)
scan(subfolder)
next
end sub