How to run abc.exe using php

两盒软妹~` 提交于 2019-11-27 08:44:56

To access the operating system with php you do the following

$answer = shell_exec("abc.exe");
echo $answer."</br>"; 

The $answer string will contain the information that the abc.exe prints out or returns.

You may need to format it using explode().

You can only run exe files if your php is runnning on a Windows machine. Futhermore, if you are on shared hostig, your hoster may have disabled the exec command.

If you are on a Windows machine, 'abc.exe' must be in the current directory or in the PATH.

To capture the output use:

exec( 'abc.exe', &$output);
echo $output;

Link to exec

morteza hosseini

You can use VaccinalBowl code in windows, but for address .exe file, see the following example :

$answer = shell_exec("D://Downloads/software/npp.6.7.9.2.Installer.exe");
echo $answer."</br>";

Encountered with permission problem even with 2&>1 (although chmod 777), but workaround by reading the output via saving into a file

See the example, cs_crypto is something to decrypt

<?php
$str = $_GET['pswd'];
$output = shell_exec("echo $str");
echo "<pre><font color='white'>$output</font></pre>";
//$output = shell_exec("echo ./cs_crypto de aesbase $str");
//$output = shell_exec("./cs_crypto de aesbase $str 2>&1");
exec("./cs_crypto de aesbase $str > out");
$output = shell_exec("tail -1 out");
//exec('./cs_crypto de aesbase $str', $output, $return_var);
//echo "<pre><font color='white'>$return_var</font></pre>";
echo "<pre><font color='white'>$output</font></pre>";
?>

So the final result in web

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!