title: How to delete all files starting with a particular name in temp folder using VBScript
body: <p>I am trying to delete all log files which start with the string "MyApp" from the Windows Temp folder using the below VB Script.</p>
  
  <pre><code>Dim objFSO
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  
  if objFSO.FolderExists("C:\Documents and Settings\guest\MyApp") Then
            set folder = objFSO.getFolder("C:\Documents and Settings\guest\MyApp") 
  
  if folder.files.Count &lt;&gt; 0 then 
      objFSO.DeleteFile "C:\Documents and Settings\guest\MyApp\*.*", True
  end if 
            objFSO.DeleteFolder "C:\Documents and Settings\guest\MyApp", True
  end if
  
  &lt;!--  The below code is not deleting the files which starts with the name "Mpp.023648011.log"   --&gt;
  
  if(objFSO.FileExists("C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*")) Then
      objFSO.DeleteFile "C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*", True
  end if
  </code></pre>
  
  <p>It seems the below check is failing:</p>
  
  <p>if(objFSO.FileExists("C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*")) </p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>I found a way to suppress the error message and execute the DeleteFile. It worked for me.</strong></p>
  
  <pre><code>     On error resume next
  
       objFSO.DeleteFile "C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*", True
  </code></pre>