Avatar of jbla9028
jbla9028
Flag for United States of America

asked on 

can't use script to access UNC path?

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
Windows Server 2008VB Script

Avatar of undefined
Last Comment
jbla9028

8/22/2022 - Mon