Function exec() calls program in the background

Asked

Viewed 364 times

2

I’m making a manager for my online game so that team members can start the emulators.exe through the site, only I’m having a problem, the emulators opens in the background on the machine (VPS)

Then I wonder if you have how to make emulators run normally, opening the executable window and not getting in the background.

<?php
if($_POST['emulador'] == "Ligar")
{
    exec("start D:\Servidor\Center\Gerenciador\ligar.bat");
    echo "<script>alert('Emulador Ativado!');</script>";
}
?>

Content of bat.:

start /d "D:\Servidor 6.4\Servidor\Center" Center.Service.exe
@echo SERVIDOR FOI INICIADO ATRAVES DO SITE
@echo CMD IRA FECHAR EM 10 SEGUNDOS, AGUARDE E NAO INTERFIRA NO PROCESSO! 
timeout 10

I was presented with this solution

if(!function_exists('pcntl_exec'))
{
    function pcntl_exec($path,$args=array())
    {
        if(is_string($args)) $args = array($args);
        if(count($args)) $path = sprintf('"%s"', $path);
        $shell = new COM('WScript.Shell');
        $shell->run($path.(count($args) ? ' '.implode(' ',$args) : ''),0,true);
    }
}
switch ($_POST['Center'])
{
    case "Ligar":
        pcntl_exec('D:\\Servidor\\Center\\Gerenciador\\ligar.bat');
        echo "<script>alert('Emulador Center Ativado!'); location.href='http://127.0.0.1/pt/?page=manager';</script>";
    break;
}

however continues to open in the background, some idea ?

  • What do you mean, "foreground"?

  • I’m sorry about the way I express myself, I just want it to open as a normal window on the server like this cmd here http://prntscr.com/i1uyrx

  • Please edit question and add your . bat content.

  • Conteudo do bat : start /d "D:\Servidor 6.4\Servidor\Center" Center.Service.exe&#xA;@echo SERVIDOR FOI INICIADO ATRAVES DO SITE&#xA;@echo CMD IRA FECHAR EM 10 SEGUNDOS, AGUARDE E NAO INTERFIRA NO PROCESSO!&#xA;timeout 10

  • tries to change the start /d for cmd /c

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.