黑松山资源网 Design By www.paidiu.com
Option Explicit
dim ServerPath,onlyone,notfinddel,WorkPath,arrWorwpath,strWorkPath,fso,wsh,WshNetwork,cName,exectime,fnum,donum,totalsize,t1,t2,tm
fnum=0
donum=0
totalsize=0
WorkPath = "F:\|D:\|C:\Download\" '这里设置需要扫描的路径(绝对路径),使用“|”来分隔多个路径
serverpath = "\\server\log$\" '在这里设置服务器上的共享文件夹(可写共享),用来存放删除日志
onlyone = "是" '设置是否只扫描一次,如果想每次运行都扫描,请改为“否”。
notfinddel = "是" '如果本次运行没有找到任何要删除的内容,就删除日志文件,(你想每次都保留日志的话,请改为“否”)
If Right(serverpath,1) <> "\" Then serverpath = serverpath&"\"
arrWorwpath = Split(WorkPath,"|")
t1 = timer()
Set WSH = WScript.CreateObject("WScript.Shell")
wsh.run "regsvr32 /s scrrun.dll",0,true
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = WScript.CreateObject("WScript.Network")
cName = WshNetwork.ComputerName
exectime = Now()
Dim dicdrv,logfile,logfilepath,Objdrv,drvTotalSize,drvFreeSpace
logfilepath = Replace(ServerPath&cName&".txt",":","-")
If Not fso.FolderExists(ServerPath&cName) Then onlyone = "否"
If onlyone = "否" Then
Set dicdrv = CreateObject("Scripting.Dictionary")
Set logfile = fso.OpenTextFile(logfilepath,8,True)
logfile.WriteBlankLines(1)
logfile.WriteLine "#####################################################"
logfile.WriteLine "开始扫描--"&Now()
logfile.WriteBlankLines(1)
For Each strWorkPath In arrWorwpath
If Right(strWorkPath,1) <> "\" Then strWorkPath = strWorkPath&"\"
scan(strWorkPath)
If Not dicdrv.Exists(UCase(Left(strWorkPath,1))&"t") Then
Set Objdrv = fso.GetDrive(fso.GetDriveName(Left(strWorkPath,2)))
dicdrv.add UCase(Left(strWorkPath,1))&"t",FormatNumber(Objdrv.TotalSize/1048576, 0)
dicdrv.add UCase(Left(strWorkPath,1))&"f",FormatNumber(Objdrv.FreeSpace/1048576, 0)
End If
Next
t2 = timer()
tm=cstr(int(( (t2-t1)*10000 )+0.5)/10)
logfile.WriteBlankLines(1)
logfile.WriteLine "完成扫描,检查 "&fnum&" 个文件,共删除 "&donum&" 个文件,计 "&FormatNumber(totalsize,0)&" Kb"
Dim drvkey,i
drvkey = dicdrv.Keys
For i = 0 To dicdrv.Count-1 Step 2
logfile.WriteLine Left(drvkey(i),1)&"盘:总计磁盘空间 "&dicdrv.Item(drvkey(i))&" M ,剩余磁盘空间 "&dicdrv.Item(drvkey(i+1))&" M"
Next
logfile.WriteLine "耗时 " & tm & " 毫秒, "&Now()
logfile.WriteLine "#####################################################"
logfile.WriteBlankLines(1)
logfile.close
If notfinddel = "是" Then
If donum = 0 Then fso.DeleteFile logfilepath,True
End If
If Not fso.FolderExists(ServerPath&cName) Then fso.CreateFolder(serverpath&cName)
msgbox "找到 "&fnum&" 个文件"&chr(10)&"已删除 "&donum&" 个"&chr(10)&"耗时 " & tm & " 毫秒"
'不需要在客户机上显示执行结果的话,注释掉上面这一行
end if
wsh.run "regsvr32 /u /s scrrun.dll",0,true
Set WshNetwork = Nothing
Set wsh=NoThing
Set FSO=NoThing
WScript.quit
Sub scan(strfolder_)
Dim folder_,files,file,ext,subfolders,subfolder
'on error resume next
Set folder_=fso.getfolder(strfolder_)
Set files=folder_.files
For Each file In files
fnum = fnum+1
ext=fso.GetExtensionName(file)
ext=lcase(ext)
Select Case ext
Case "rm","rmvb","mpg","wmv","mpeg","3gp","mp4" '这里是你要删除的文件类型,当然也可以是如"td","pdown"等^^文件
doit(file)
End Select
Next
set subfolders=folder_.subfolders
For Each subfolder In subfolders
If subfolder.name <> "System Volume Information" And subfolder.name <> "RECYCLER" Then
scan(subfolder)
End If
Next
End Sub
Sub doit(file)
Dim strtemp,lngsize,strsizeV
strtemp = file.path
lngsize = clng(file.size/1024)
donum=donum+1
totalsize = totalsize + lngsize
'fso.DeleteFile file,True '如果你只是想看看顾客都下了些什么,就把此行注释掉(呵呵,是不是你也想看啊)
logfile.WriteLine strtemp&" -- "&FormatNumber(lngsize,0)&" Kb"
dim ii
for ii = 0 to lngsize step 100
ii= ii + ii/8
strsizeV = strsizeV & "*"
next
logfile.WriteLine "---"&strsizeV
end Sub
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年11月13日
2024年11月13日
- 梁咏琪.1996-爱自己【EEI】【WAV+CUE】
- IGN经典逆天骚操作名著——《墙头草修炼手册》
- 突然爆火的“网红游戏”,真的有那么多人玩吗?
- 何老师客串《浪人崛起》了?盘点与明星撞脸的角色!
- 【原神】关于星鹫赤羽对珐芙琴班配队下珐露珊主C的适配度分析
- 【原神】V5.1攻略 | 迪西雅角色简评
- 【原神】大日御舆顶端怎么上去
- 胥拉齐《感谢有你》DTS-WAV
- 罗海英《金牌歌后》【WAV+CUE】
- 林叶《林叶·夜》【WAV/分轨】
- 群星《国语经典名曲01》音乐磁场系列[WAV+CUE][1G]
- 齐豫《滚石24K》24K金碟珍藏版系列[低速原抓WAV+分轨][1G]
- 齐秦《齐秦[三洋母带] 》1:1母盘直刻限量版[WAV分轨][1G]
- 英雄联盟双城之战第二季在哪里看 双城之战第二季观看地址分享
- 宝可梦大集结公测耿鬼怎么获取 耿鬼获取方法一览