Results 1 to 6 of 6

Thread: Running batch files from PHP code...

  1. #1
    <<== UT3 Player spoon_'s Avatar
    Join Date
    Nov 2008
    Location
    London
    Posts
    2,071
    Thanks
    113
    Thanked
    139 times in 131 posts

    Running batch files from PHP code...

    What's not playing the ball in the code below?

    Quote Originally Posted by script
    <?php
    if(isset($_POST['submit']))
    {
    echo exec('C:\Run.bat');
    echo "Done!";
    } else {
    // display the form
    ?>
    <form action="" method="post">
    <input type="submit" name="submit" value="Run The God Damn Thing!">
    </form>
    <?php
    }
    ?>
    I'm running IIS 5.1 / PHP 5.2.13

    Please feel free to assume that my knowledge of PHP is non-existent lol

    Any help, much appreciated.

  2. #2
    PHP Geek Flash477's Avatar
    Join Date
    Dec 2008
    Location
    Devon
    Posts
    822
    Thanks
    51
    Thanked
    72 times in 65 posts

    Re: Running batch files from PHP code...

    The \ is an escape character in PHP, so

    c:\Run.bat

    is actually

    c:Run.bat

    You want:

    c:\\Run.bat

  3. #3
    <<== UT3 Player spoon_'s Avatar
    Join Date
    Nov 2008
    Location
    London
    Posts
    2,071
    Thanks
    113
    Thanked
    139 times in 131 posts

    Re: Running batch files from PHP code...

    Good tip but it didn't work...


    P.S.

    There is only one 'u' in Curiosity so got a little typo there

  4. #4
    PHP Geek Flash477's Avatar
    Join Date
    Dec 2008
    Location
    Devon
    Posts
    822
    Thanks
    51
    Thanked
    72 times in 65 posts

    Re: Running batch files from PHP code...

    Is PHP running in safe mode?

  5. #5
    <<== UT3 Player spoon_'s Avatar
    Join Date
    Nov 2008
    Location
    London
    Posts
    2,071
    Thanks
    113
    Thanked
    139 times in 131 posts

    Re: Running batch files from PHP code...

    None of the settings in php.ini indicates that, no.

  6. #6
    HEXUS.social member Agent's Avatar
    Join Date
    Jul 2003
    Location
    Internet
    Posts
    19,185
    Thanks
    739
    Thanked
    1,614 times in 1,050 posts

    Re: Running batch files from PHP code...

    First off (ripped from PHP.net)

    PHP Code:

    <?php
    function exec_enabled() {
      
    $disabled explode(', 'ini_get('disable_functions'));
      return !
    in_array('exec'$disabled);
    }
    ?>
    That will allow you to see if exec() is disabled.

    Secondly, what OS? If you're running anything recent (Vista, Windows 7, Server 08) then it could be a UAC issue, depending on what the .bat is actually trying to do. Although I would expect a UAC pop-up if this was the case.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Windows - hotfixing overview
    By Paul Adams in forum Software
    Replies: 13
    Last Post: 13-10-2009, 11:17 AM
  2. Vista and batch file to copy files to XP machine
    By andrewpmoore in forum Software
    Replies: 3
    Last Post: 01-02-2007, 09:41 PM
  3. How do you backup?
    By Howard in forum PC Hardware and Components
    Replies: 48
    Last Post: 05-01-2005, 09:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •