We have just implemented a SAN solution and I am trying to run a script (that works on the local server) that looks to a share across the network to delete all files in folders and subfolders and I am receiving an error message stating:
Error: Permission denied
Source: Microsoft VBScript runtime error
I am logged in as a domain admin and have full rights to the server that I am trying to kick it off on.
I have attached the script, however, if I run it on the local server and point to the drive letter it works fine.
Any help would be greatly appreciated.
Dim fso, startFolder, OlderThanDate
Set fso = CreateObject("Scripting.FileSystemObject")
startFolder = "\\sadvnfs01\Scan-DVN\" ' folder to start deleting (subfolders will also be cleaned)
OlderThanDate = DateAdd("d", -7, Date) ' 7 days (adjust as necessary)
DeleteOldFiles startFolder, OlderThanDate
Function DeleteOldFiles(folderName, BeforeDate)
Dim folder, file, fileCollection, folderCollection, subFolder
Set folder = fso.GetFolder(folderName)
Set fileCollection = folder.Files
For Each file In fileCollection
If file.DateLastModified < BeforeDate Then
Set folderCollection = folder.SubFolders
For Each subFolder In folderCollection
DeleteOldFiles subFolder.Path, BeforeDate