0
votes

I've been trying to run a php file using window task scheduler. I've tried using the .bat file, but it won't work. Here's what I've done:

  • I've created a task "Download Image"
  • I've created a .bat file, and the content is:

    "C:\xampp\php\php.exe" -f "D:\server\newxml\download.php";

  • The php file that I want to run is:

        ini_set('max_execution_time', 300);
        $doc = simplexml_load_file('xml_edit_feeds.xml');
    
        foreach ($doc->xpath("//item") as $item) {
            $name = $item->productname;
            $realname = preg_replace('/\s/', '',$name);
            $url = $item->thumbnail_url;
            $img = 'D:/server/newxml/imagethumbnail/'.$realname.'.png';
            $filename = 'D:server/newxml/imagethumbnail/'.$realname.'.png';
                file_put_contents($img, file_get_contents($url));
        }
    ?>
    
  • This is the screen shoot of the windows task scheduler: enter image description here

Action tab

Is there something wrong from what I did? Thank you for your help

2
you dont need the bat file, you can put that command line in scheduler - user6763587

2 Answers

0
votes

I didn't try this before, but I think you should use a browser exe program to open your webpage instead of php.exe.

0
votes

Eureka! I got the answer to this, so, I what I've done is:

  • Set the Program/Script to: C:\xampp\php\php.exe
  • Set the arguments to: D:\path\to\php.php (In my case D:\server\newxml\download.php)
  • Set the start-in to the folder that contains download.php (php file that you want to run). In my case: D:\server\newxml\