I am running a Win2k3 server with IIS 6 with PHP 5 installed as a CGI executable.
I have the following code:
<?php
exec("c:\windows\system32\schtasks.exe /Query", $output);
print_r($output);
?>
In 'schedule.php', which runs fine on my local test server (Win XP, Apache, PHP 5) returning an array containing all the scheduled tasks on this computer.
When migrated to the server the page loads with no PHP errors, however returns an empty array. It also appears that schtasks is not run.
I suspect this is to do with windows user permissions. So added %COMPUTERNAME%/IUSR_%COMPUTERNAME% to the security tag of the C:\ and D:\ drives and the C:\PHP folder, C:\WINDOWS, C:\WINDOWS\System32 and also SCHTASKS.exe. No avail - still no exec() command.
I have queried the server using the php system() command which returns no username, but implies that the default user profile is being used to run the page. Code used as follows:
<?php
echo '<pre>';
system('set', $retval);
echo ' </pre>';
?>
I am wanting to use exec() to run schtasks and query scheduled tasks, create tasks and delete them so I can do server maintenance from a web interface.
Using ASP is not really an option as there is a possibility that in the future it may need to be run on a Linux based system.
Thanks for any help in advance. Much appreciated!!
James Darbyshire
PHP Systems Developer