Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
浏览器挂起运行Powershell的执行PHP_Php_Powershell_Exec_Shell Exec - Fatal编程技术网

浏览器挂起运行Powershell的执行PHP

浏览器挂起运行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,它运行一个powershell脚本, 如果使用此代码,我会在命令窗口中获得结果,但在浏览器中会得到一个空数组:

<?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*