C++/VB - Script to report folder sizes?

Asked By Rich
08-Mar-10 01:00 PM
I have a Users directory on a drive, where all my users have a subfolder with
their user name.  inside everyone's folder is a certain folder, lets call it
TooBig, that i need to know the size for for each user.  does anyone have a
script that would maybe dump the size of each user's TooBig folder to a file
I can review?
WScript.CreateObject
(1)
WshShell.Environment
(1)
ObjFSO.GetFolder
(1)
WScript.Shell
(1)
Scripting.FileSystemObject
(1)
WshSysEnv
(1)
Database
(1)
Report
(1)
  Pegasus [MVP] replied to Rich
08-Mar-10 02:22 PM
There are numerous tools ready-made for just this purpose, most of them
free. Here are two of them:
- DriveUse:
http://members.ozemail.com.au/~nulifetv/freezip/freeware/index.html
- Bullet Proof Folder sizes: http://www.foldersizes.com/
If you prefer to write your own then I am sure someone would help you, as
long as you start with a solid idea and are prepared to do most of the
coding yourself.
  Kevin Bumber replied to Pegasus [MVP]
15-Mar-10 10:40 AM
Rich,

Here is something we have running on our network to find the size of
users 'My Documents' directory. Our flavor runs at log-on on a users
computer. You may be able to modify this to meet your needs. The
version below will echo the results of the users profile size, instead
of echoing the results we write them to a database.

'VBScript
Const CONVERSION_FACTOR = 1048576

'you need to access the environment variables from the system
Set WshShell = WScript.CreateObject("WScript.Shell")

'then tell the shell object to look at the environment variables with
a type of
'Process
Set WshSysEnv = WshShell.Environment("PROCESS")

'populate the 'sprofile' variable with the contents of the
'USERPROFILE'
sProfile = WshSysEnv("USERPROFILE")

Set objFSO = CreateObject("scripting.FileSystemObject")

set objFolder = objFSO.GetFolder(sProfile)

'Here you convert the bits result from objFolder.size to MB'
iSize = objFolder.size / CONVERSION_FACTOR

Wscript.Echo iSize
Create New Account
help
Dim strLine Dim strNumLines Dim strFrank Dim strHeader Dim strFooter Dim strNewText Set objFSO = CreateObject("Scripting.FileSystemObject") Set strLocalFolder = objFSO.GetFolder("C: \ PHFN007") Set WshShell = WScript.CreateObject("WScript.Shell") Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 For Each strFile In strLocalFolder.Files
same thing? Thanks. Dim oHtml, ws, myText Dim oShell Set oHtml = CreateObject("htmlfile") Set ws = WScript.CreateObject("WScript.Shell") ' Copy the selection. set oShell = CreateObject("WScript.Shell") oShell.SendKeys"^c" ' Convert clipboard data into string. myText = oHtml.parentwindow.clipboardData.getData("text") ' Use just the first instance. myText = RegEx.Replace(myText, "'") ' convert string back to clipboard: Set oAutoIt = WScript.CreateObject("AutoItX3.Control") oAutoIt.ClipPut(myText) VBScript Discussions CreateObject (1) Expression (1) SendKeys (1) Control (1
see it with Active Directory and the sAMAccountName is good ? '- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Const adPosEOF = -3 Set objConnection = Wscript.CreateObject("ADODB.Connection") Call objConnection.Open ("Provider = ADsDSOObject;") Set objCommand = Wscript.CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.CommandText = "<LDAP: / / DC = yourcenar, DC = local" _ & "> ;(ObjectCategory = user is the good example of my problematic script (I hope :-)) : '############################### Const adPosEOF = -3 Set objConnection = Wscript.CreateObject("ADODB.Connection") Call objConnection.Open ("Provider = ADsDSOObject;") Set objCommand = Wscript.CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.CommandText = "<LDAP: / / DC = yourcenar, DC = local" & _ Set objRecord
Failed". Thanks = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Const ForReading = 1 Const ForWriting = 2 Dim objShell Set objShell = Nothing Set objShell = WScript.CreateObject ("WScript.shell") Set objRegEx = CreateObject("VBScript.RegExp") objRegEx.Pattern = "Degraded" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C: \ Program Files \ IBM \ SDDDSM \ datapath_query.txt", ForReading) Set objtivoli = objFSO wwpn > > . \ sdddsm_tivoli_status.txt" Next End If Loop objFile.Close objRegEx.Pattern = "Failed" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C: \ Program Files \ IBM \ SDDDSM \ datapath_query.txt", ForReading) Do Until objFile
this possible? For example, if I had something simple like this: Dim WshShell Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "C: \ tests.txt" And say the file does not exist, how do I scripting help file: http: / / www.microsoft.com / download / en / details.aspx?displaylang = en&id = 2764 WScript.Shell is a small component that adds a few odds and ends to Windows Script Host unless you put extra quotes around the path, because it has a space in it. WScript.Shell will try to run "C: \ tests" with a command line of "again.txt". For file