We have a number of printers that scan to a public folder, and we used to have a scheduled task set up that ran a VBScript that emptied the folder of documents that were over 7 days old every sunday. I'll post the script below, the script runs fine when run by itself, but the problem we're having is that the script used to run with the credentials of the NT AUTHORITY/SYSTEM account, which now doesn't work, the task just sits there as if its running, then nothing. No output message. When we run the task with a domain account it runs fine. Any ideas? We'd prefer to run it under the system account.
NB i've also been told that we have this problem with running ANY VBScripts or batch files.
' Autor: Fernando Inácio
' Date: 02-03-2006
' Description : Deletes files of a certain date and time.
' It also generates an output of the total number of deleted
' files and creates a log file.
strDateTime = "16-02-2006"
strPath = "D:\G\scanner\UAT"
strDatediff= " "
intFileCount = 0
strComputer = "."
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set logFile= objFSO.CreateTextFile(strPath & "\deleteFiles.log", True)
Set Folder = objFSO.GetFolder(strPath)
logFile.Write "Directory Name: " & strPath & VbCrLf
logFile.Write "Date: " & Now() & VbCrLf & VbCrLf
For Each file In Folder.Files
if DateDiff("d", File.DateLastModified, Now) >= 7 Then
intFileCount = intFileCount + 1
logFile.Write "File: " & File.name & vbTab & vbTab & File.DateLastModified & VbCrLf
objFSO.DeleteFile(strPath & "\" & file.name)
If intFileCount = 0 Then
MsgBox "No files to delete!"
MsgBox intFileCount & " files deleted!"
logFile.Write intFileCount & " File Deleted."
Set lofFile = Nothing
Set objFSO = Nothing
Set Folder = Nothing