title: how can i use obj.sendkeys Method based on output of previous statement executed in command line through VBScript
body: <p>Batch File</p>
  
  <pre><code>`cscript test.vbs`
  </code></pre>
  
  <p>VbsCRIPT file namesd Test</p>
  
  <pre><code>`set obj=WScript.CreateObject("WScript.Shell")
  obj.SendKeys "cd  c:\users\hp\documents"
  Wscript.sleep 200
  obj.SendKeys {ENTER}
  obj.SendKeys "dir"
  Wscript.sleep 200` 
  </code></pre>
  
  <p><strong>this is where code is supposed to decide</strong></p>
  
  <p><code>obj.SendKeys "xcopy c:\users\hp\documents\today D:\MyBackups /E"
      Wscript.sleep 200</code></p>
  
  <p>i want to execute next statement only if the folder <strong>today</strong> is present in the list which comes after typing dir</p>
  
  <p>so the main question is how can i make the system decide based on the output of previous statement</p>
  
  <p>this is the basic part only.
  Every day's backup takes different time to copy based on size.
  I want to wait for the next statement to execute only after previous one is executed successfully
  i.e if files are copied successfully then execution of the file should proceed</p>
  
  <p>any help is appreciated
  <em>please ignore syntactic error. i made it working in my system somehow and this question is posted through phone when i didn't had my system</em></p>