简体   繁体   中英

Problems running PHP script using Task Scheduler (Windows Server 2008 R2)

I am using a Virtual Machine on Windows Azure. It is running Windows Server 2008 R2 Datacenter Service Pack 1.

I have a PHP script that does some routine work which includes connecting online and saving a few images from my website.

I have created a batch file called myScript.bat as follows:

"C:\Program Files (x86)\PHP\v5.3\php.exe" -f "C:\Users\Username\Desktop\MyFolder\m.php"

Pretty simple. It works great when I double click and run the .bat file. The PHP script does it's job.

Now, the problem arises when I try to schedule the task using Task Scheduler.

In General I have selected: Run only when the user is logged on and Run with highest privileges

In the Trigger tab, I have set the trigger, say, for every hour.

And in Actions tab I have added the following:

Start a program - C:\\Users\\Username\\Desktop\\MyFolder\\myScript.bat


Now. when I Run this task, I get a bunch of error messages like this:

Warning: file_get_contents(http://...): failed to open stream: ...
Warning: copy(images/image11942.jpg): failed to open stream: No such file or directory in C:\Users\Username\Desktop\MyFolder\m.php

etc.

I have tried enabling all permissions for MyFolder and its subfolders, but still no help.

Any idea what might be causing this issue?

I have had a similar issue running a script as a Scheduled Tasks from the Desktop. When I moved it to a folder on the C: drive, I had no further problems.

Hope this helps....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM