title: vbs(25, 3) Microsoft VBScript runtime error: Invalid procedure call or argument
body: <p>I wrote a script to grab the list for folders from a file and it will check and delete for files that are more than 90 days old.</p>
  
  <p>The script was able to delete the files older than 90 days. However I keep on getting an error saying:</p>
  
  <blockquote>
    <p>D:\cleanup90days.vbs(25, 3) Microsoft VBScript runtime error: Invalid procedure call or argument</p>
  </blockquote>
  
  <p>I don't have an idea what I have missed. Any help will be appreciated.</p>
  
  <p>Below is my script:</p>
  
  <pre><code>Dim days
  Dim inputFolderList, ObjFolder, Files, objFileAge
  
  If Not WScript.Arguments.Count = 2 Then
      Wscript.Echo "Invalid number of arguments. Arg1: Daily or Weekly. Arg2: Remove all files older then this"
      WScript.Quit(-1)
  End If
  
  days = WScript.Arguments.Item(1)
  
  inputFileList = "D:\FileGrep2.txt"
  Set Fso = CreateObject("Scripting.FileSystemObject")
  Set objTextFile = fso.OpenTextFile(inputFileList, 1)
  
  Do Until objTextFile.AtEndOfStream
      sFolderName = objTextFile.ReadLine
      getfoldernames(sFolderName)
  Loop
  
  Function getfoldernames(sFolderName)
      Set ObjFolder = fso.GetFolder(sFolderName)
      Set Files = ObjFolder.Files
  
      For Each Check In Files
          objFileAge = DateDiff("n", Check.DateLastModified, Now)
          If objFileAge &gt; 90 Then
              WScript.Echo Now &amp; "the following will be deleted " &amp; Check.Path
              Check.Delete
          End If
      Next
  End Function
  </code></pre>