Solved

VBScript - Folder Size to CSV - 70-Permission Denied

Posted on 2014-03-04
10
573 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now