« Previous Next »

Thread: IIS 6; PHP 5; MSSQL 2000; PHP exec() command

Last post 12-04-2008 11:15 PM by brashquido. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 12-04-2008, 9:10 PM

    IIS 6; PHP 5; MSSQL 2000; PHP exec() command

    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
  • 12-04-2008, 9:26 PM In reply to

    Re: IIS 6; PHP 5; MSSQL 2000; PHP exec() command

    Similarly I have had a look at this thread (below). Don't think the responses re: virtual directories make a difference as I cannot even load an external .exe which loads on the server.

    http://forums.iis.net/t/1149900.aspx
    James Darbyshire
    PHP Systems Developer
  • 12-04-2008, 11:15 PM In reply to

    Re: IIS 6; PHP 5; MSSQL 2000; PHP exec() command

     Have you checked the schtasks.exe file itself? From memory all Windows system/system32 files are explicitly set to deny access to the IUSR account. I wrote a guide on how to enable the exec() function to work on IIS which might be some help to you.

    ----------------
    Dominic Ryan
    Microsoft IIS MVP
    www.iis-aid.com
    My IIS articles
    My PHP articles
    My How-to guides
Page 1 of 1 (3 items)
Microsoft Communities