title: Php Script to delete and create files and folder using .bat not working when run using Windows Scheduler
body: <p>I was trying create folder and save images using php in loop, it is running fine from <strong>.bat</strong> file manually.</p>
  
  <p><strong>It is creating all respective folders and image files, but when run using windows scheduler its is not creating folders.</strong> </p>
  
  <p>The job is successfully completed when checked the Scheduler status. </p>
  
  <p>Also I ran a delete to clean up old folders and images this also works fine if I ran the .bat file manually but not deleting any folder when run through scheduler.</p>
  
  <p><strong>The below is the .bat file code.</strong></p>
  
  <p><strong>Am I missing some permission issue in Scheduler that prevent me from creating folder and images?</strong></p>
  
  <pre><code>c:\xampp\php\php.exe -f c:\xampp\htdocs\retrieve_image.php
  </code></pre>
  
  <p>This is the bat file code I have created to run the *.php file</p>
  
  <pre><code>while ($row = $db-&gt;fetch_array($r2)) {
  
          $sysid = $row[ml_num];
          $prop_id = $row[property_id];
  
  
          $n = 1;
          $dir = 'photos/' . $sysid;
          if (!is_dir($dir)) mkdir($dir); 
  
          $photos = $rets-&gt;GetObject('Property', 'Photo', $sysid);            
          foreach ($photos as $photo) {
              $loc = $dir . "/" . $n . ".jpg";
              file_put_contents($dir . '/' . $n . '.jpg', $photo['Data']);
  
              if (imagecreatefromjpeg($loc) !== false) {
                  echo $loc . "&lt;br/&gt;";
                  $sql2 = "INSERT INTO property_images(property_id, pimg_name,status) values('$prop_id','$loc',1)";
  
                  $r3 = $db-&gt;query($sql2);
              }
              else
              {
                  $status = unlink($loc);
              }
              $n++;
  
          }
  
          $i++;
      }
  </code></pre>
  
  <p>This is the php code to retrieve image and create a new folder and put images in while loop. It is working fine when I ran .bat file manually. </p>
  
  <p><strong><em>Please help me in running this action through windows scheduler.</em></strong></p>