OK I have this script I am using to delete files from a directory and when I run it I get this VBScript Error... 800A0046 Permission Denied... I have tried running it as the Administrator, I have tried giving everyone Full Control to the director but I can not seem to get this script to get past this. Can someone give me some suggestions.
Below is the first part of the code that executes the file delete and where I am getting the error. The error happens on the deleting of the files.
Set objFolder = objFSO.GetFolder("C:\SportsTicker\xmlfiles\")
Set filesys = CreateObject("Scripting.FileSystemObject")
For Each file in objFolder.Files
Set objTextStream = objFSO.OpenTextFile(objFolder & "\" & file.Name)
fname = left(file.name,11)
fnamelog = right(file.name,9)
if ucase(fnamelog) = ucase("inj-r.xml") or ucase(fnamelog) = ucase("log-r.xml") or ucase(fnamelog) = ucase("ros-r.xml") then
set demofile = filesys.GetFile(objFolder & "\" & file.Name)
Maybe my code is wrong and the error is just because the files don't exist. So here is what I am trying to do. I am trying to delete all the files that have inj-r.xml , ros-r.xml and log-r.xml as the last 9 characters of the file name.