|
correy
初级用户
积分 97
发帖 22
注册 2007-4-23
状态 离线
|
『楼 主』:
[原创]清除垃圾的VBS文件
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
|
|
2007-10-1 08:28 |
|
|
wudixin96
银牌会员
积分 1928
发帖 931
注册 2007-1-6
状态 离线
|
『第
2 楼』:
建议多使用GetSpecialFolder方法
|
|
2007-10-1 08:34 |
|
|
slore
铂金会员
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第
3 楼』:
left(subfolder.path,6)="recent" or left(subfolder.path,7)="cookis"
这种判定方式……汗一个……不知道有没有lcase
|
|
2007-10-1 11:04 |
|
|
Nickey
初级用户
积分 132
发帖 59
注册 2007-8-23 来自 GuangZhou
状态 离线
|
『第
4 楼』:
晕死
好像某些系统文件都被删了
提示无法识别请插入安装盘
咋办?
|
|
2007-10-1 18:48 |
|
|
yjq635
初级用户
积分 109
发帖 42
注册 2007-5-12
状态 离线
|
『第
5 楼』:
我发一个VBS版的,,
dim fs,f,fc
Const temporaryfolder=2
On Error Resume Next
Set fs=CreateObject ("Scripting.filesystemObject")
Set fs=fs.getspecialfolder(2)
Set fc=fs.subfolders
For each f in fc
f.delete true
Next
Set fc=fs.files
For each f in fc
f.delete true
Next
|
|
2007-10-1 22:57 |
|
|
icyheart
中级用户
积分 216
发帖 81
注册 2007-8-6
状态 离线
|
『第
6 楼』:
学习啦拿来修改修改呵呵
|
Crossings must be my teacher
Modest progress can be |
|
2007-10-2 12:27 |
|
|
huangxiaohao
初级用户
积分 29
发帖 15
注册 2007-10-6
状态 离线
|
|
2007-10-6 10:22 |
|