폴더 크기 체크해서 파일로 찍기 (VBS) Etc.2010. 1. 8. 13:21
' Directory to Monitor
varPath = "C:\Windows"
varResultFile = "C:\DirSize.csv"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(varPath)
SumFiles = f.size
SumFiles = SumFiles / 1048576
SumFiles = Round(SumFiles,2)
Set fso = NOTHING
Set f= NOTHING
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objItem in colItems
dtmLocalTime = objItem.LocalDateTime
dtmMonth = Mid(dtmLocalTime, 5, 2)
dtmDay = Mid(dtmLocalTime, 7, 2)
dtmYear = Left(dtmLocalTime, 4)
dtmHour = Mid(dtmLocalTime, 9, 2)
dtmMinutes = Mid(dtmLocalTime, 11, 2)
dtmSeconds = Mid(dtmLocalTime, 13, 2)
Next
strNow = dtmYear & "/" & dtmMonth & "/" & dtmDay & "," & dtmHour & ":" & dtmMinutes & ":" & dtmSeconds
Set objWMIService = NOTHING
Set colItems = NOTHING
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(varResultFile, ForAppending, True)
objTextFile.WriteLine(strNow&",Directory Size:,"&sumfiles&"MB")
objTextFile.Close
Set objFSO = NOTHING
Set objTextFile = NOTHING