MartyConnelly
martyconnelly at shaw.ca
Mon Nov 10 21:43:47 CST 2003
I was just curious how much space was taken up by uninstalls for WinXP both Service packs and hotfixes so I wrote this quick piece of code up It just grabs the directory file size and totals the up. Mine came to around 500 Mb for files such as C:\WINDOWS\$NtServicePackUninstall$ C:\WINDOWS\$NtUninstallKB282010$ Option Compare Database Option Explicit 'WriteFile("c:\windows") Public Function WriteFile(filespec) Dim objFSo Dim oFolder Dim cFolder Dim sReport Dim sUnit Dim s As String Dim ltot As Long ltot = 0 Set objFSo = CreateObject("Scripting.FileSystemObject") ' Set sReport = objFSo.OpenTextFile("SpaceReport.TXT", ForAppending, True) ' sReport.Close Set oFolder = objFSo.GetFolder(filespec) Set cFolder = oFolder.SubFolders For Each sUnit In cFolder 'If MinVal < sUnit.Size Then ' WriteFile (sUnit) If Mid(sUnit, 1, 14) = "C:\WINDOWS\$NT" Then ltot = ltot + sUnit.Size s = ShowFolderSize(sUnit) Debug.Print s ' Set sReport = objFSo.OpenTextFile("SpaceReport.TXT", ForAppending, True) ' sReport.WriteLine s ' sReport.Close End If Next Debug.Print "total=" & ltot & " - " & ByteFilter(ltot) End Function Public Function ShowFolderSize(filespec) As String Dim FSO As Object Dim f As Object Dim BF As String Dim s As String If Right(filespec, 1) <> "\" Then filespec = filespec & "\" End If Set FSO = CreateObject("Scripting.FileSystemObject") Set f = FSO.GetFolder(filespec) 'wscript.echo (f.size/1024) ' If Minval < f.size then BF = ByteFilter(f.Size) s = BF & vbTab & " are being used in: " & vbTab & UCase(filespec) ShowFolderSize = s ' End If End Function '---ByteFilter Function...---------------- Public Function ByteFilter(ByteQuant) As String Dim BF As String If ByteQuant < 1024 Then BF = ByteQuant & vbTab & vbTab & "Bytes " End If If 1024 <= ByteQuant And ByteQuant < 1048576 Then BF = CStr(ByteQuant / 1024) & vbTab & vbTab & "KiloBytes" End If If 1048576 <= ByteQuant And ByteQuant < 1073741824 Then BF = CStr(ByteQuant / 2 ^ 20) & vbTab & vbTab & "MegaBytes" End If If 1073741824 <= ByteQuant Then BF = CStr(ByteQuant / 2 ^ 30) & vbTab & vbTab & "GigaBytes" End If ByteFilter = BF End Function -- Marty Connelly Victoria, B.C. Canada