Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute C# application in PHP

I am new to PHP and I am trying to run a c# application I've developed, from my PHP project. The app is local and is on the same machine as the server.
I should only be able to execute the app (preferably run it in background), since it's output is printed in a separate file which I access in my website.

Is there any way to run the app from my website ? I've tried to use echo exec(...) but it won't work.

like image 580
Bogdan Molinger Avatar asked Mar 17 '26 02:03

Bogdan Molinger


1 Answers

Use something like:

<?php
function _exec($cmd)
{
   $WshShell = new COM("WScript.Shell");
   $oExec = $WshShell->Run($cmd, 0,false);
   echo $cmd;
   return $oExec == 0 ? true : false;
}

_exec("yourprogram.exe");
?>

More info at: http://php.net/manual/en/function.exec.php

Also the user running the web server will need elevated permissions.

like image 76
Mihai Dinculescu Avatar answered Mar 18 '26 15:03

Mihai Dinculescu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!