I have a php script and an exe file created using c#. I want php to execute that exe file. I tried to use shell_exec
command. But nothing is happening!! Then I tried echo shell_exec("dir");
and it works by displaying the info.
Why is it not executing the exe file. Few months back I have used it and it worked fine on xpdf, brc and opera.
I tried giving absolute path, I tried adding to path variable. But its not working. Interesting thing is that my exe file executes perfectly from command Line . I think something is wrong with php.
I am using Apache 2.4 and PHP 5.6
PHP Script:
<?php
echo shell_exec("Face_Trainer.exe");
?>
C# exe file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Face_Trainer
{
class Program
{
static void Main(string[] args)
{
Console.Beep();
}
}
}
I need this shell_exec to work to complete my project, everything else is fine, just this function!
You are using a non interactive shell, that is why you don't hear a beep. You can check it with writing a file, if a file is created your program runs fine in your current setup.
Other remarks:
If you really try to execute an exe file you should use the right extension:
<?php
echo shell_exec("Face_Trainer.exe");
?>
Since that seems to be an typo, here comes another hint: I would run a batch file where you setup your environment for your application. Here an example:
@echo off
set path=%path%;x:\your\path
cd x:\dir\of\exe
Face_Trainer.exe
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.