PHP on a windows machine; Start process in background

后端 未结 5 1357
无人及你
无人及你 2020-12-10 06:46

I\'m looking for the best, or any way really to start a process from php in the background so I can kill it later in the script.

Right now, I\'m using: shell_exec($C

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 07:34

    Will this function from the PHP Manual help?

    function runAsynchronously($path,$arguments) {
        $WshShell = new COM("WScript.Shell");
        $oShellLink = $WshShell->CreateShortcut("temp.lnk");
        $oShellLink->TargetPath = $path;
        $oShellLink->Arguments = $arguments;
        $oShellLink->WorkingDirectory = dirname($path);
        $oShellLink->WindowStyle = 1;
        $oShellLink->Save();
        $oExec = $WshShell->Run("temp.lnk", 7, false);
        unset($WshShell,$oShellLink,$oExec);
        unlink("temp.lnk");
    }
    

提交回复
热议问题