Welcome Guest, Not a member yet? Register   Sign In
Run .exe file from ci3 in IIS server
#1

Code:
I want to run an .exe program from Codeigniter 3 on an IIS server, but it doesn't do anything. Does anyone know how to configure the IIS server so that I can start an .exe program?
<?php
$answer = shell_exec("c:\inetpub\vhosts\programozas.org\ci3\OlszCommandLine.exe");
echo $answer."</br>";
?>
Reply
#2

To get a literal backslash and not to escape a character, you need to double the backslahes:

PHP Code:
<?php
$answer 
shell_exec("c:\\inetpub\\vhosts\\programozas.org\\ci3\\OlszCommandLine.exe");
echo 
$answer."</br>";
?>
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(09-21-2021, 03:36 PM)includebeer Wrote: To get a literal backslash and not to escape a character, you need to double the backslahes:

PHP Code:
<?php
$answer 
shell_exec("c:\\inetpub\\vhosts\\programozas.org\\ci3\\OlszCommandLine.exe");
echo 
$answer."</br>";
?>

not work: pictures here 
Reply
#4

There may be other problems, but the problem with your path was the first of them...
I don't see your error message.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

I solved !
<link rel="shortcut icon" href="#">
<?php 
//phpinfo();
error_reporting(E_ALL);

$output=null;
$retval=null;
//exec('c:\inetpub\vhosts\programozas.org\cgi-bin\OlszCommandLine.exe TOKENEXCHANGE  C:\TMP\VALASZ.TXT', $output, $retval);
exec('..\cgi-bin\OlszCommandLine.exe TOKENEXCHANGE  C:\TMP\VALASZ.TXT', $output, $retval);
//exec('dir',$output,$retval);
echo "Returned with status $retval and output:\n";
print_r($output);

?>

-Must use IUSER in IIS
Which is a huge lesson for me:
1.I was expecting the exe to physically start, but since this is a server here nothing physical is running!
2. My program was expecting parameters and I did not specify them, the above code will help to highlight this. After giving the parameters also the exe no longer wrote an error message.
3.I saw the run as working by getting an answer.txt t in the c: \ tmp directory that contained the tokenxchage of the online account.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB