Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.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
PHP proc_open()适用于cmd.exe,但不适用于powershell.exe_Php_Powershell_Cmd_Window - Fatal编程技术网

PHP proc_open()适用于cmd.exe,但不适用于powershell.exe

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") //

我正在尝试使用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") // 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