title: Make log for deleted files using VBScript
body: <p>The below is my code to delete DAT files.</p>
  
  <pre><code>OPTION EXPLICIT
  DIM strExtensionsToDelete,strFolder
  DIM objFSO, MaxAge, IncludeSubFolders
  
  ' ************************************************************
  ' Setup
  ' ************************************************************
  
  ' Folder to delete files
  strFolder = "E:\test"
  ' Delete files from sub-folders?
  includeSubfolders = true
  ' A comma separated list of file extensions
  ' Files with extensions provided in the list below will be deleted
  strExtensionsToDelete = "dat"
  ' Max File Age (in Days).  Files older than this will be deleted.
  maxAge = 0
  
  ' ************************************************************
  
  set objFSO = createobject("Scripting.FileSystemObject")
  
  DeleteFiles strFolder,strExtensionsToDelete, maxAge, includeSubFolders
  
  wscript.echo "Finished"
  
  sub DeleteFiles(byval strDirectory,byval strExtensionsToDelete,byval maxAge,includeSubFolders)
  DIM objFolder, objSubFolder, objFile
  DIM strExt
  
  set objFolder = objFSO.GetFolder(strDirectory)
  for each objFile in objFolder.Files
      for each strExt in SPLIT(UCASE(strExtensionsToDelete),",")
          if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." &amp; strExt then
              IF objFile.DateLastModified &lt; (Now - MaxAge) THEN
                  wscript.echo "Deleting:" &amp; objFile.Path &amp; " | " &amp; objFile.DateLastModified 
                  objFile.Delete
                  exit for
              END IF
          end if
      next
  next    
  if includeSubFolders = true then ' Recursive delete
      for each objSubFolder in objFolder.SubFolders
          DeleteFiles objSubFolder.Path,strExtensionsToDelete,maxAge,includeSubFolders
      next
  end if
  end sub
  </code></pre>
  
  <p>Now i want to create a log files to store the deleted files information (such as name of the file, when the script is run and user who run this script). Can any one help me with this ? </p>
  
  <p>Thanks in Advance..</p>