Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


File Size on User Profile Folder (SystemFolder) results in Perm Error

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61186
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> File Size on User Profile Folder (SystemFolder) results in Perm Error
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 File Size on User Profile Folder (SystemFolder) results... - 6/8/2008 9:47:55 PM   
  asgaroth

 

Posts: 12
Score: 0
Joined: 5/14/2008
Status: offline
Hello there,

i am currently writing a script that logs the folder sze of the user profile folder into a file.
I found out how to get the folder size but i always get a permission denied error (800A0046) on "Folder.size".
I have full access to the folder (cause its currently my user profile folder) and the special permission "view attributes" is also granted.
In another forum they said that this error can occur if the folder is not really a folder. I rechecked this with Folder.type and it says "Systemfolder".

What am i doing wrong?

My code is:

Function GetFolderSize(thepath)
   Dim fold, fso
   Set fso = CreateObject("Scripting.FileSystemObject")
 
   If fso.FolderExists(thepath) Then
       Set fold = fso.getFolder(thepath)
       GetFolderSize = fold.size
       Exit Function
   Else
       GetFolderSize = -3
       Exit Function
   End If
End Function

I tried setting thepath to C:\Users\MyUsername\ (currently working under vista) or setting it to %userprofile%  (i don't know if this works... if not i have to find a way to determine the right path).

When accessing C:\Users\MyUsername\Desktop\  everything works fine and strangely Folder.type says: "File".

Thanks in advance for your help.
 
 
Post #: 1
 
 RE: File Size on User Profile Folder (SystemFolder) res... - 6/9/2008 12:21:32 AM   
  Rischip


Posts: 468
Score: 2
Joined: 3/26/2007
Status: offline
Are you passing the string with double qoutes? If you are, try it without them. Your function works for me on XP, passing it like this...

WScript.Echo GetFolderSize("C:\Documents and Settings\myusername")

_____________________________

Rischip
Author of - The Grim Linker

(in reply to asgaroth)
 
 
Post #: 2
 
 RE: File Size on User Profile Folder (SystemFolder) res... - 6/11/2008 10:00:42 PM   
  asgaroth

 

Posts: 12
Score: 0
Joined: 5/14/2008
Status: offline
What do you mean "without double quotes" ? 
Like this? WScript.Echo GetFolderSize(C:\Users\myusername) ?
That results in an error...

I tried my script on a ms-XP box and it works fine there... it seems that the permission error is vista related.
So its okay because the script will only be run on w2003 or something...

but i'll nevertheless appreciate  it if anybody has any ideas how to get around the error

For my %userprofile% problem, i found out that there is the following useful method:

wshShell.ExpandEnvironmentStrings("%userprofile%")

That seems to work fine.

Best regards, asgaroth

(in reply to Rischip)
 
 
Post #: 3
 
 RE: File Size on User Profile Folder (SystemFolder) res... - 6/13/2008 10:12:13 AM   
  Rischip


Posts: 468
Score: 2
Joined: 3/26/2007
Status: offline
No what I meant with the double quotes was.... If you are quoting the string in such a way as to ensure that it is passed to the function quoted to account for spaces in the path.

i.e. myPath = """C:\documents and settings\someusername\desktop"""
or
myPath = Chr(34) & "C:\documents and settings\someusername\desktop" & Chr(34)





This works for me.....


      

_____________________________

Rischip
Author of - The Grim Linker

(in reply to asgaroth)
 
 
Post #: 4
 
 RE: File Size on User Profile Folder (SystemFolder) res... - 6/17/2008 9:38:00 PM   
  asgaroth

 

Posts: 12
Score: 0
Joined: 5/14/2008
Status: offline
I was now told that it is possible that the script is run by some vista computers. so i need either to get the filesize on vista or if thats not possible, write an error message into the logfile.

@Rischip, on what machine did you try that code? I like to know if it works on other vista machines.

Best regards,
           asgaroth

(in reply to Rischip)
 
 
Post #: 5
 
 RE: File Size on User Profile Folder (SystemFolder) res... - 6/18/2008 12:21:53 AM   
  dm_4ever


Posts: 2432
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
Getting the folder size of users in Vista does not work from what I remember.....using WMI might provide a workaround though....can't recall right now.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to asgaroth)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> File Size on User Profile Folder (SystemFolder) results in Perm Error Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts