Yeah... I don't like Windows programming - but I'm doing a job and I need some help.

I basically need to execute a .bat file from PHP, but it doesn't seem to work (In ZEND, but that doesn't really matter too much... Since it runs php/apache) - it doesn't run at all, and sometimes, after running my script, I open the .bat file in notepad and see everything has been changed into Japanese.

<?
exec("run c:\test.bat");
?>

Can anyone help me here? 🙁

Edit: The .bat file just runs "notepad.exe" - nothing real complex...

Exec seems to work when I use it on a .jpg... Strange enough as it is

    can you clarify?

    you ran:
    exec("run c:\picture.jpg");
    and it opens the jpg somewhere?

    are you running directly on the server?

    if this works for .jpg and not .bat,
    i think it's safe to say that the Windows server has a restriction on running an exec on an executable file (the irony).

    what are you trying to open notepad for?
    just curious, it might help

    -findapollo

      Originally posted by findapollo
      can you clarify?

      you ran:
      exec("run c:\picture.jpg");
      and it opens the jpg somewhere?

      are you running directly on the server?

      if this works for .jpg and not .bat,
      i think it's safe to say that the Windows server has a restriction on running an exec on an executable file (the irony).

      what are you trying to open notepad for?
      just curious, it might help

      -findapollo

      Yes it opens the jpg, no I'm not running it on a server (I'm running it on Win XP pro, through ZEND)...
      How can I set it up so it doens't have restrictions
      and I'm just trying to run notepad through a .bat, to test to see if this works.

        Sorry man, I could help you if you were on an Apache based configuration of PHP.

        I'm sure there is some similar configuration in Win32 though.

        It has to do with the php.ini file in my arena. I don't know Zend, nor have I really ever used PHP on Win32.
        I would suggest reading the documentation on the Zend site for Windows exec()....look for links about configuration.

        Sorry I couldn't help.

          Err... Zend uses Apache and php... Not anything special - just the builds you can download from their sites (Apache and php's sites, that is)

            but on Windows...I only have experience with LAMP solutions (Linux/Apache/PHP)

              Holy shit... heres the answer that I'm astonished nobody already said:

              exec('c:\test.bat');

              Why your feeble mind might ask? Well because in languages such as perl, php, c++, and such strings use '\' sort of as if it is a variable, like \0 is zero byte, \n is newline, etc... so in order to get a real '\', you need to double it up.

              This is an extremely common thing with php on windows servers, I typically use '/' instead since its simpler, and it works on all OSes (that I know of).

              By the way, Hello all, this is my first post on this board _

                Write a Reply...