Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtain and record the size of specific folders?

Status
Not open for further replies.
Feb 22, 2005
39
BM
How can I obtain and record the size of specific folders such as the cookies, temp, temp internet folders on a Windows XP machine? Is their some kind of counter I can set up? or a script I can run on a daily basis?
Thanks!
 
'chuck the below in a .vbs file and give it a run :)

Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")
Call getFolderInfo("%systemdrive%\test")
Call getFolderInfo("c:\test2")
Set FSO = Nothing
Set WshShell = Nothing

Sub getFolderInfo(strPassed)
Dim objFolder
strPassed = WshShell.ExpandEnvironmentStrings(strPassed)
If FSO.FolderExists(strPassed) Then
Set objFolder = FSO.GetFolder(strPassed)
Wscript.Echo strPassed & "=" & objFolder.Size
Set objFolder = Nothing
Else
Wscript.Echo strPassed & "=notfound"
End If
End Sub
 
Thanks!!! Works like a charm.
Is it possible to output this to a word doc or notepad file?
 
when you run it from a command prompt do something like

cscript.exe thescript.vbs > c:\results.txt

you can chuck it in a word doc from within the vbs but you would need to expose a word COM object and i am eating my lunch :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top