PHP proc_open()适用于cmd.exe,但不适用于powershell.exe
我正在尝试使用proc_open打开“powershell.exe”shell。网页持续加载。但是,它适用于“cmd.exe”shell。我不明白这有什么区别 这是我的密码PHP proc_open()适用于cmd.exe,但不适用于powershell.exe,php,powershell,cmd,window,Php,Powershell,Cmd,Window,我正在尝试使用proc_open打开“powershell.exe”shell。网页持续加载。但是,它适用于“cmd.exe”shell。我不明白这有什么区别 这是我的密码 <?php $descriptorspec = array( 0 => array("pipe", "r"), // stdin 1 => array("pipe", "w"), // stdout 2 => array("file", "error.txt", "a") //
<?php
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("file", "error.txt", "a") // stderr
);
$process = proc_open("powershell.exe", $descriptorspec, $pipes);
if (is_resource($process)) {
fwrite($pipes[0], "hostname \n");
fclose($pipes[0]);
echo( '<pre>' );
echo stream_get_contents($pipes[1]);
echo( '</pre>' );
fclose($pipes[1]);
$return_value = proc_close($process);
echo "command returned $return_value\n";
}
?>
编辑1
观察任务管理器后,我了解到powershell.exe在后台创建cmd.exe。是否有一种方法可以通过'proc_open'获取PHP中的子进程的引用您是否可以尝试
proc_open(“powershell.exe?@Ohgoodwhy嗨,我刚才试过了。相同状态-保持加载您能验证事件查看器中是否有可能提供更多信息的内容吗?Google Chrome控制台提供-“应用程序缓存无更新事件”。只是没别的了
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\wamp\bin\apache\Apache2.2.17>hostname
GOKPRAVE-WS01
C:\wamp\bin\apache\Apache2.2.17>
command returned 0