title: Constantly look for file, when file exist, run command
body: <p>I need a vbscript that monitors a folder for a specific file, when file is found it needs to execute a command then delete that file but continue to monitor the folder again for the same file incase it needs to run again.  </p>
  
  <p>This...</p>
  
  <pre><code>Set FSO = CreateObject("Scripting.FileSystemObject")
  Do While 1&gt;0
     If FSO.FileExists (file.txt) Then 
         FSO.DeleteFile (file.txt)
         CreateObject("WScript.Shell").Run "c:\windows\notepad.exe"
     End If
     WScript.Sleep 1000
  Loop
  </code></pre>
  
  <p>Gave me an <code>"object required: file"</code> error.</p>
  
  <p>update, this worked...</p>
  
  <pre><code>FileName = "c:\vbscript\cat.txt"
  Set FSO = CreateObject("Scripting.FileSystemObject")
  Do
     If FSO.FileExists(FileName) Then 
         FSO.DeleteFile FileName
         CreateObject("WScript.Shell").Run "c:\windows\notepad.exe"
     End If
     WScript.Sleep 1000
  Loop
  </code></pre>