Vbscript Help RRS feed

  • Question

  • Hi - am trying to determine the folder size on the local machine. But for some reason it does not calculate the ProgramData folder. The script is

    Total = 0
    StrComputer = "."
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objParentFolder = objFSO.GetFolder("C:\")
    For Each objSubfolder in objParentFolder.Subfolders
    'wscript.echo objSubFolder.Name
       GetFolderSize objSubfolder
    Sub GetFolderSize(Folder)
       Dim lInt, aDecimalPlaces, strSize
       If Folder.Name <> "Program Files" and Folder.Name <> "Documents and Settings" and Folder.Name <> "Program Files (x86)" and  Folder.Name <> "Windows" Then
    wscript.echo Folder.Name & " Size is - " & Folder.Size
    Total = Total + FormatNumber((CDbl(Folder.Size)/1024/1024))
       End If
    End Sub

    • Moved by Bill_Stewart Tuesday, November 7, 2017 10:04 PM Help vampire
    Friday, September 22, 2017 8:04 PM

All replies

  • ProgramData is only visible if you are elevated or if you explicitly ask for the folder by name.

    This can be done in PowerShell in  one line without elevation:

    Get-ChildItem c:\ -Directory -force


    • Edited by jrv Friday, September 22, 2017 8:54 PM
    Friday, September 22, 2017 8:53 PM