Thursday, March 19, 2015

Folder Size

On Error Resume Next

Dim oFS, oFolder, UserName, path1,UserProf
set oFS = WScript.CreateObject("Scripting.FileSystemObject")
Dim WshShell: Set WshShell = CreateObject("Wscript.Shell")'Declare Global Shell Object
'UserName = WshShell.ExpandEnvironmentStrings ("%USERNAME%")
UserName = WScript.Arguments.Item(0)
NoteFilesPath = WScript.Arguments.Item(1)
UserProf = WshShell.ExpandEnvironmentStrings ("%USERPROFILE%")
path1=chr(34) & UserProf & "\Local Settings\Application Data\Lotus\Notes\Data" & chr(34)
set oFolder = oFS.GetFolder(NoteFilesPath)
'ShowFolderDetails oFolder


sub ShowFolderDetails(oF)
dim F
    wscript.echo  oF.Size

end sub

Dim sh

'msgbox oFolder.Size
Size=oFolder.Size

'msgbox size
size=SizeOnDisk(Size,4096)

Set sh = CreateObject("Wscript.shell")

sh.RegWrite "HKLM\Software\Folder_size\CopyFoldersizeA", Size,"REG_SZ"

Function SizeOnDisk(intFileSize,intClusterSize)
        If (intFileSize <= intClusterSize) Then
                SizeOnDisk = intClusterSize
        Else
                Dim intBase : intBase = intFileSize / intClusterSize
                If Int(intBase) <> intBase Then
                        intBase = int(intBase) + 1
                        SizeOnDisk = (intBase * intClusterSize)
                End If
        End If
 End Function

No comments:

Post a Comment