Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Script Problem - Permission denied error

Reply
 
Old 12-20-2008   #1 (permalink)
Mark Ivey


 
 

Script Problem - Permission denied error

I am having trouble with a script. I was wanting to use this script to
examine my file servers and let me know any files that have not been
modified in the past 3 years and list them in a csv file.

The script works fine on some systems, but others through a Permission
Denied error...

Has anyone encountered this type of problem?

Any help is greatly appreciated...

Mark Ivey

Here is my code...

Dim filcolInfo
Set objFSO = CreateObject("Scripting.FilesyStemObject")
myFolder="c:\" ' drive you want searched
Set objFolder = objFSO.GetFolder(myFolder)
GoSubFolders objFolder
WriteDataFile filcolInfo

Sub GoSubFolders (objDIR)
MainSub objDIR
For Each eFolder in objDIR.SubFolders
GoSubFolders eFolder
Next
End Sub

Sub MainSub (objDIR)
For Each efile in objDIR.Files
If efile.DateLastModified < (Date() - 1095) Then ' 1095 days is
approximately 3 years
filcolInfo = filcolInfo & efile.DateLastModified & ", " & objDIR & "\" &
efile.Name & vbCrLf
End If
Next
End Sub

Sub WriteDataFile(filcolInfo)
'Set New Folder name with today's date
yy = DatePart("yyyy", DateAdd("d", -1, Date))
mon = DatePart("m", DateAdd("d", -1, Date))
If Len(mon) = 1 Then
mon = "0" & mon
End If
dd = DatePart("d", DateAdd("d", 0, Date))
If Len(dd) = 1 Then
dd = "0" & dd
End If

Set NewFile = objFSO.CreateTextFile("C:\Old File Listing_" & yy & mon &
dd & ".csv", True)
NewFile.Write filcolInfo
NewFile.Close
End Sub


My System SpecsSystem Spec
Old 12-20-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Script Problem - Permission denied error


"Mark Ivey" <wmivey6311@xxxxxx_(do_not_spam)> wrote in message
news:0BC09033-0016-4BDA-8555-8F97B9F4577B@xxxxxx
Quote:

>I am having trouble with a script. I was wanting to use this script to
>examine my file servers and let me know any files that have not been
>modified in the past 3 years and list them in a csv file.
>
> The script works fine on some systems, but others through a Permission
> Denied error...
>
> Has anyone encountered this type of problem?
>
> Any help is greatly appreciated...
>
> Mark Ivey
>
> Here is my code...
>
> Dim filcolInfo
> Set objFSO = CreateObject("Scripting.FilesyStemObject")
> myFolder="c:\" ' drive you want searched
> Set objFolder = objFSO.GetFolder(myFolder)
> GoSubFolders objFolder
> WriteDataFile filcolInfo
>
> Sub GoSubFolders (objDIR)
> MainSub objDIR
> For Each eFolder in objDIR.SubFolders
> GoSubFolders eFolder
> Next
> End Sub
>
> Sub MainSub (objDIR)
> For Each efile in objDIR.Files
> If efile.DateLastModified < (Date() - 1095) Then ' 1095 days is
> approximately 3 years
> filcolInfo = filcolInfo & efile.DateLastModified & ", " & objDIR & "\" &
> efile.Name & vbCrLf
> End If
> Next
> End Sub
>
> Sub WriteDataFile(filcolInfo)
> 'Set New Folder name with today's date
> yy = DatePart("yyyy", DateAdd("d", -1, Date))
> mon = DatePart("m", DateAdd("d", -1, Date))
> If Len(mon) = 1 Then
> mon = "0" & mon
> End If
> dd = DatePart("d", DateAdd("d", 0, Date))
> If Len(dd) = 1 Then
> dd = "0" & dd
> End If
>
> Set NewFile = objFSO.CreateTextFile("C:\Old File Listing_" & yy & mon &
> dd & ".csv", True)
> NewFile.Write filcolInfo
> NewFile.Close
> End Sub
On some OS's (like Vista) users (even Administrators) lack permissions to
read files in certain folders. Figure out which statements raise the errors
and trap them with "On Error Resume Next". These two statements should raise
permission denied errors:

For Each eFolder in objDIR.SubFolders
For Each efile in objDIR.Files

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 12-20-2008   #3 (permalink)
Mark Ivey


 
 

Re: Script Problem - Permission denied error

Richard,

Thanks so much for your advise...

I will see if I can trap the error as you stated...

Mark Ivey

"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
message news:Ocfjz8rYJHA.6000@xxxxxx
Quote:

>
> "Mark Ivey" <wmivey6311@xxxxxx_(do_not_spam)> wrote in message
> news:0BC09033-0016-4BDA-8555-8F97B9F4577B@xxxxxx
Quote:

>>I am having trouble with a script. I was wanting to use this script to
>>examine my file servers and let me know any files that have not been
>>modified in the past 3 years and list them in a csv file.
>>
>> The script works fine on some systems, but others through a Permission
>> Denied error...
>>
>> Has anyone encountered this type of problem?
>>
>> Any help is greatly appreciated...
>>
>> Mark Ivey
>>
>> Here is my code...
>>
>> Dim filcolInfo
>> Set objFSO = CreateObject("Scripting.FilesyStemObject")
>> myFolder="c:\" ' drive you want searched
>> Set objFolder = objFSO.GetFolder(myFolder)
>> GoSubFolders objFolder
>> WriteDataFile filcolInfo
>>
>> Sub GoSubFolders (objDIR)
>> MainSub objDIR
>> For Each eFolder in objDIR.SubFolders
>> GoSubFolders eFolder
>> Next
>> End Sub
>>
>> Sub MainSub (objDIR)
>> For Each efile in objDIR.Files
>> If efile.DateLastModified < (Date() - 1095) Then ' 1095 days is
>> approximately 3 years
>> filcolInfo = filcolInfo & efile.DateLastModified & ", " & objDIR & "\"
>> & efile.Name & vbCrLf
>> End If
>> Next
>> End Sub
>>
>> Sub WriteDataFile(filcolInfo)
>> 'Set New Folder name with today's date
>> yy = DatePart("yyyy", DateAdd("d", -1, Date))
>> mon = DatePart("m", DateAdd("d", -1, Date))
>> If Len(mon) = 1 Then
>> mon = "0" & mon
>> End If
>> dd = DatePart("d", DateAdd("d", 0, Date))
>> If Len(dd) = 1 Then
>> dd = "0" & dd
>> End If
>>
>> Set NewFile = objFSO.CreateTextFile("C:\Old File Listing_" & yy & mon
>> & dd & ".csv", True)
>> NewFile.Write filcolInfo
>> NewFile.Close
>> End Sub
>
> On some OS's (like Vista) users (even Administrators) lack permissions to
> read files in certain folders. Figure out which statements raise the
> errors and trap them with "On Error Resume Next". These two statements
> should raise permission denied errors:
>
> For Each eFolder in objDIR.SubFolders
> For Each efile in objDIR.Files
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
cannot restart print spooler error 5 permission denied General Discussion
Ran script once and it worked, now permission denied error...? VB Script
vbscript error 70 - permission denied VB Script
permission denied problem Vista security
Runtime Error Permission Denied Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46