Solved

VBScript - Folder Size to CSV - 70-Permission Denied

Posted on 2014-03-04
10
581 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

809 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