![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||