Solved

VBScript - Folder Size to CSV - 70-Permission Denied

Posted on 2014-03-04
10
579 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 191
Auto-indent certain lines in Notepad++ 10 73
Need VB Script to scan through XML file and export content to csv file 9 32
VB.net and sql server 4 33
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 …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

808 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