浏览器挂起运行Powershell的执行PHP
我正在尝试运行一个简单的PHP,它运行一个powershell脚本, 如果使用此代码,我会在命令窗口中获得结果,但在浏览器中会得到一个空数组:浏览器挂起运行Powershell的执行PHP,php,powershell,exec,shell-exec,Php,Powershell,Exec,Shell Exec,我正在尝试运行一个简单的PHP,它运行一个powershell脚本, 如果使用此代码,我会在命令窗口中获得结果,但在浏览器中会得到一个空数组: <?php exec("powershell C:\\Inetpub\\wwwroot\\my_shell.ps1 < NUL", $output); echo "<pre>"; print_r($output); echo "</pre>"; ?> 如果我这样做,结果也是一样的: $cmd = "cmd.
<?php
exec("powershell C:\\Inetpub\\wwwroot\\my_shell.ps1 < NUL", $output);
echo "<pre>";
print_r($output);
echo "</pre>";
?>
如果我这样做,结果也是一样的:
$cmd = "cmd.exe";
&$cmd "/C echo update tasks set last='manual' where id='8'; | sqlplus vvv/www@xxx";
如果我独立运行powershell脚本,它运行良好:
Stop-Process -processname powershell*
因此,我需要在浏览器中执行此操作并获取输出。powershell进程没有终止,这会导致浏览器挂起。将以下内容添加到脚本末尾
信息不足。请发布
powershell
命令正在运行的代码。-看这里。Microsoft建议运行Set-ExecutionPolicy RemoteSigned-Scope LocalMachine。这允许计算机上的所有用户帐户无问题地运行本地脚本,但需要确认才能运行从internet下载的脚本。@SeeSharp执行策略工作正常,我可以直接从powershell运行脚本,谢谢。
$cmd = "cmd.exe";
&$cmd "/C echo update tasks set last='manual' where id='8'; | sqlplus vvv/www@xxx";
Stop-Process -processname powershell*