📜 VBScript (WSH)
Get The system-wide Windows Temp folder Size Report (VBScript)
Recursively sums the size of the system-wide Windows Temp folder, read-only (no deletion).
GetWindowsTempSizeReport.vbs
' ============================================================
' GetWindowsTempSizeReport.vbs
'
' Reports how much disk space the system-wide Windows Temp folder is using, read-only.
'
' Usage: cscript GetWindowsTempSizeReport.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:\Windows\Temp"
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"