删除 N 天以前的指定类型文件
作者:Starland 日期:2008-09-13 11:45:44
dtmDate = Date - 7
strDay = Day(dtmDate)
If Len(strDay) < 2 Then
strDay = "0" & strDay
End If
strMonth = Month(dtmDate)
If Len(strMonth) < 2 Then
strMonth = "0" & strMonth
End If
strYear = Year(dtmDate)
strTargetDate = strYear & strMonth & strDay
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\Scripts'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
strDate = Left(objFile.CreationDate, 8)
If strDate < strTargetDate Then
If objFile.Extension = "bak" Then
objFile.Delete
End If
End If
Next
评论: 0 |
引用: 0 |
查看次数: 806
发表评论
上一篇
下一篇
文章来自:
Tags: