Solved

VBScript - Folder Size to CSV - 70-Permission Denied

Posted on 2014-03-04
10
583 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In this post we will learn different types of Android Layout and some basics of an Android App.
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?
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

762 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