troubleshooting Question

can't use script to access UNC path?

Avatar of jbla9028
jbla9028Flag for United States of America asked on
Windows Server 2008VB Script
2 Comments1 Solution837 ViewsLast Modified:
I have borrowed this script from the interweb in order to delete files older than X days within a unc path. the script will work locally on the pc but when I put a UNC path in under "sDirectoryPath =" the script does not work. Any Ideas? I'm a network admin, not a programmer so any help would be highly appreciated!

iDaysOld = 1
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "\\d0002\D\test"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files
'If database log file backups are older than "iDaysOld" days, delete them.
For each oFile in oFileCollection
      If oFile.DateLastModified < (Date() - iDaysOld) Then
            oFile.Delete(True)
      End If
Next


'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing

Sub RecurseFolders(oFolder)
      set oFileCollection = oFolder.Files
      'If database log file backups are older than "iDaysOld" days, delete them.
      For each oFile in oFileCollection
            If oFile.DateLastModified < (Date() - iDaysOld) Then
                  oFile.Delete(True)
            End If
      Next      
      End Sub
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros