title: IF exist for scheduled task
body: <p>I have created a batch file to check if scheduled task exists and if they don't create them, however, my if exist rule seem to always hit true even though the jobs are not there.</p>
  
  <p>Any ideas?</p>
  
  <pre><code>::Check Rule
  IF EXIST SchTasks /QUERY /TN "Cache Task Morning"  ( 
      echo ! Morning rule in place!
      GOTO NEXT 
  ) ELSE IF NOT EXIST SchTasks /Create /SC DAILY /TN "Cache Task Morning" /TR "C:\Cache Clear\Cache Clear.bat" /ST 09:00 
  
  :NEXT
  IF EXIST SchTasks /QUERY /TN "Cache Task Afternoon"  ( 
      echo ! Afternoon rule in place!
      GOTO NEXT TWO
  ) ELSE IF NOT EXIST SchTasks /Create /SC DAILY /TN "Cache Task Afternoon" /TR "C:\Cache Clear\Cache Clear.bat" /ST 15:00 
  
  :NEXT TWO
  IF EXIST SchTasks  /QUERY /TN "Cache Task Evening"  ( 
      echo ! Evening rule in place!
      GOTO CLEAR CACHE 
  ) ELSE IF NOT EXIST SchTasks /Create /SC DAILY /TN "Cache Task Evening" /TR "C:\Cache Clear\Cache Clear.bat" /ST 18:00 
  </code></pre>