I needed to write a VB Script to audit the maximum file size on a bunch of workstations. To do this in VBS its very simple with only a few lines of code using the .Size option with the folder object you declare under the Scripting.FileSystemObject API. I have demonstrated the code required to grab the file size below in blue.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\boessenc!\)
Wscript.Echo objFolder.Size
Running this code on ANY folder on a Vista/2008 or higher workstation will give you a Permission denied error:
Microsoft VBScript runtime error: Permission denied
Running this on any older version of Windows such as Windows XP or 2003 works without problems. The test above I ran the script against my users profile - a folder which of course my account has access to demonstrating the issue.
I also tested running this script against the WMI database with the FileSize property of the Win32_Directory class. That doesn't work either.
As a result need to utilise another method for grabbing the directory size.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\boessenc!\)
Wscript.Echo objFolder.Size
Running this code on ANY folder on a Vista/2008 or higher workstation will give you a Permission denied error:
Microsoft VBScript runtime error: Permission denied
Running this on any older version of Windows such as Windows XP or 2003 works without problems. The test above I ran the script against my users profile - a folder which of course my account has access to demonstrating the issue.
I also tested running this script against the WMI database with the FileSize property of the Win32_Directory class. That doesn't work either.
As a result need to utilise another method for grabbing the directory size.
No comments:
Post a Comment