Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript - Folder Size to CSV - 70-Permission Denied

Posted on 2014-03-04
10
Medium Priority
?
589 Views
Last Modified: 2014-03-09
Hi Guys,

I've wrote the following script but when executing it on certain folders I get 70-Permission Denied. I definately have permission to that folder so not sure whats going on there.

Dim objFSO, objFolder, F
Const ForAppending = 8
strFolderSrc = "C:\Users\singh763173"

Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolderSrc)
Set objLogFile = objFSO.OpenTextFile("test.csv", ForAppending)

ShowFolderDetails objFolder

Sub ShowFolderDetails(oF)
	objLogFile.Writeline
	objLogFile.Write oF.Size & ","
	objLogFile.Write oF.Files.count & ","
	objLogFile.Write oF.Subfolders.count

objLogFile.Close
End Sub

Open in new window


Any help?

Many thanks in advance!
0
Comment
Question by:Amarjot Singh
  • 6
  • 4
10 Comments
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39904620
Try to Run as Administrater
0
 

Author Comment

by:Amarjot Singh
ID: 39904624
Tried that. Same issue.
0
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39904636
Run CMD as Run as Administrater and then type
wscript scriptname
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Amarjot Singh
ID: 39904646
That is exactly what I am doing - Cscript rather than Wscript as I want to trap any output within the console.
0
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39904810
Hi, this script is working fine too me.

try to run this script for your profile first.
0
 

Author Comment

by:Amarjot Singh
ID: 39904821
Tried my profile but still the same.

If you change the path to c:\windows, can you tell me if it works?
0
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39904924
its working for most of the folders but not for system folders. pls try after disabling the UAC.
http://www.howtogeek.com/howto/windows-vista/disable-user-account-control-uac-the-easy-way-on-windows-vista/
0
 

Author Comment

by:Amarjot Singh
ID: 39905533
I need it to work with UAC enabled as this will run on a machine with Group Policy enforced on it.
0
 

Accepted Solution

by:
Amarjot Singh earned 0 total points
ID: 39905812
Figured it out - The script works but not where sub folders have been ACLd without my permissions - I have subfolders that didn't have my or the administrator permissions assigned.

I will therefore need to create a group which has Full Control permissions assigned and create a service account to add to it. Then add a scheduled task with the service account to run every hour.
0
 

Author Closing Comment

by:Amarjot Singh
ID: 39915678
Solution found.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Loops Section Overview
Screencast - Getting to Know the Pipeline

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question