Script Fails with Error

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 16 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ayth
Posts: 10
Last visit: Mon Nov 26, 2007 8:51 pm

Script Fails with Error

Post by ayth »

Hey Guys,

I'm writing a script which will delete old files in certain specified folders. The script logs which files it deletes, in a file called ddmmyy.log, basically day month year .log.

At the end of the script, I am writing something to clean out the old log files. Here is the script portion that I'm talking about:

Code: Select all

strScript = WScript.ScriptFullName
strScriptName = WScript.ScriptName
Set objFile = objFSO.GetFile(strScript)
objFile = CStr(objFile)
Set objParent = objFSO.GetParentFolderName(objFile)

For Each strFile In objParent.Files
    If strFile = strScriptName Then
        Else
        strDateCreated = strFile.DateCreated
        strDateSince = DateDiff("d", strDateCreated, Now)
            If  strDateSince > 7 Then
                strFile.Delete
            End If
    End If
Next
Problem is I'm getting the following error. Any ideas on where I'm going wrong? Thanks.

This topic is 16 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked