coder4life
coder4life

Reputation: 65

Windows PHP scheduled task to restart service does not work

PHP version 5.2.2.6 OS: Windows Server 2003

I am trying to write a PHP script that will periodically check several windows services and restart any that are not running.

1) When I run from the web, the script works correctly.

2) When I run as scheduled tasks, the script runs but is unable to start any services. I tried to output to a log text file. I see that it reports all services as stopped (even though some aren't), issues a service start for each but nothing happens. When I run the script from DOS prompt, same result.

I've tried various ways to start service and I get the same result. EX:

system('net start ApDSCService');

I also tried this example but same results: http://hotware.wordpress.com/2008/08/26/restarting-windows-services-in-a-php-script/

I don't have the option to upgrade the PHP version as it would break some other sites hosted on the server. Any help would be appreciated.

Upvotes: 1

Views: 498

Answers (1)

baptme
baptme

Reputation: 10092

Change the user in scheduled task (administrator if you can)

Upvotes: 1

Related Questions