中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-06-21 12:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [原创]清除垃圾的VBS文件 查看 828 回复 6
楼 主 [原创]清除垃圾的VBS文件 发表于 2007-10-01 08:28 ·  中国 河南 郑州 电信
初级用户
积分 97
发帖 22
注册 2007-04-23 00:29
19年会员
UID 86125
性别 男
状态 离线
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
本帖最近评分记录 (共 1 条) 点击查看详情
评分人分数时间
wudixin96 +3 2007-10-01 08:34
2 发表于 2007-10-01 08:34 ·  中国 天津 电信
银牌会员
★★★
积分 1,928
发帖 931
注册 2007-01-06 11:46
19年会员
UID 75624
性别 男
状态 离线
建议多使用GetSpecialFolder方法
3 发表于 2007-10-01 11:04 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
19年会员
UID 79003
性别 男
状态 离线
left(subfolder.path,6)="recent" or left(subfolder.path,7)="cookis"
这种判定方式……汗一个……不知道有没有lcase
4 发表于 2007-10-01 18:48 ·  中国 广东 广州 白云区 电信
初级用户
★★
积分 132
发帖 59
注册 2007-08-23 21:24
18年会员
UID 95705
性别 男
来自 GuangZhou
状态 离线
晕死
好像某些系统文件都被删了
提示无法识别请插入安装盘
咋办?
5 发表于 2007-10-01 22:57 ·  中国 安徽 合肥 电信
初级用户
积分 109
发帖 42
注册 2007-05-12 09:38
19年会员
UID 88253
性别 男
状态 离线
我发一个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
6 发表于 2007-10-02 12:27 ·  中国 山西 临汾 联通
中级用户
★★
积分 216
发帖 81
注册 2007-08-06 12:23
18年会员
UID 94721
性别 男
状态 离线
学习啦拿来修改修改呵呵
Crossings must be my teacher
Modest progress can be
7 发表于 2007-10-06 10:22 ·  中国 云南 红河哈尼族彝族自治州 电信
初级用户
积分 29
发帖 15
注册 2007-10-06 09:40
18年会员
UID 99007
性别 男
状态 离线
正在学习,相信对我会有帮助的
论坛跳转: