📜 VBScript (WSH)

Get IIS log files Size Report (VBScript)

Recursively sums the size of IIS log files, read-only (no deletion).

By WindowsScripting.com · 1.1 KB
GetIISLogsSizeReport.vbs
' ============================================================
' GetIISLogsSizeReport.vbs
'
' Reports how much disk space IIS log files is using, read-only.
'
' Usage: cscript GetIISLogsSizeReport.vbs
' ============================================================

Option Explicit

Function FolderSize(objFSO, objFolder)
    Dim total, objFile, objSub
    total = 0
    On Error Resume Next
    For Each objFile In objFolder.Files
        total = total + objFile.Size
    Next
    For Each objSub In objFolder.SubFolders
        total = total + FolderSize(objFSO, objSub)
    Next
    On Error Goto 0
    FolderSize = total
End Function

Dim objFSO, objShell, objFolder, targetPath, totalBytes

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

targetPath = "C:\inetpub\logs\LogFiles"

If Not objFSO.FolderExists(targetPath) Then
    WScript.Echo targetPath & " does not exist on this machine."
    WScript.Quit
End If

Set objFolder = objFSO.GetFolder(targetPath)
totalBytes = FolderSize(objFSO, objFolder)

WScript.Echo targetPath
WScript.Echo "  Total size: " & Round(totalBytes / 1024 / 1024, 2) & " MB"