Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2007
    Location
    England
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Script To Run Windows Commandline

    Hi All,

    Could someone please point me in the direction of making a PHP web script process a Windows commandline either directly or running a batch file..?

    The scenario is this:

    I have a file directory of ISO images for my network. I have Daemon tools installed on my network server which runs a WAMP Server. What i want to happen is to produce a webpage so that you can select the image you require from a drop down menu. Then when you click some sort of mount button on the webpage, the PHP script either directly or through an MSDOS batch file mounts the images to Daemon tools depending on what image you have selected.

    Many Thanks,

    Blackfish

  • #2
    New Coder
    Join Date
    Dec 2007
    Location
    UK
    Posts
    41
    Thanks
    1
    Thanked 7 Times in 7 Posts
    I think you might want to start looking here:

    http://uk2.php.net/manual/en/function.exec.php

    EDIT: Here is an example I found. It works but you may need to change the permissions on c:\windows\system32\cmd.exe to allow the Internet Guest Account read/execute perms.

    PHP Code:
    <?php
    $data 
    = array(); // define array

    $cmd "c:/test.bat";
    exec($cmd$data$ret); // execute command, output is array


    echo "<pre>";
    if (
    $ret == 0)
    // check status code. if successful
    foreach ($data as $line)
    // process array line by line
    echo "$line\n";
    }
    }
    else
    {
    echo 
    "Error in command"// if unsuccessful display error
    }
    echo 
    "</pre>";
    ?>
    Now all you need to do is see if Daemon tools has command line support.
    Last edited by tonyyeb; 01-04-2008 at 02:59 PM.

  • #3
    New Coder
    Join Date
    Mar 2007
    Location
    England
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tonyyeb View Post
    I think you might want to start looking here:

    http://uk2.php.net/manual/en/function.exec.php
    I did take a look at this but didn't find it very helpful unfortunately

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I'm going to have to go with tonyyeb. You have to use exec() to execute programs.

  • #5
    New Coder
    Join Date
    Dec 2007
    Location
    UK
    Posts
    41
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by blackfish View Post
    I did take a look at this but didn't find it very helpful unfortunately
    Check my edit above ^^^^^^^

    Also here are the Daemon tool command line switches. Should be a doddle now!

    http://www.daemon-help.com/index.php..._line_switches

  • #6
    New Coder
    Join Date
    Mar 2007
    Location
    England
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent guys, thanks very much for your help, I shall update you on the results


  •  

    Posting Permissions

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