PHP calls the com component wscript.shell to execute the dos command_PHP tutorial

WBOY
Release: 2016-07-20 11:06:32
Original
1828 people have browsed it

/php调用com 组件wscript.shell执行dos命令
  p('


');
  if ($execfunc=='wscript' && IS_WIN && IS_COM) {
   $wsh = new COM('WScript.shell');
   $exec = $wsh->exec('cmd.exe /c '.$command);
   $stdout = $exec->StdOut();
   $stroutput = $stdout->ReadAll();
   echo $stroutput;
  } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
   $descriptorspec = array(
      0 => array('pipe', 'r'),
      1 => array('pipe', 'w'),
      2 => array('pipe', 'w')
   );
   $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
   if (is_resource($process)) {
    fwrite($pipes[0], $command."rn");
    fwrite($pipes[0], "exitrn");
    fclose($pipes[0]);
    while (!feof($pipes[1])) {
     echo fgets($pipes[1], 1024);
    }
    fclose($pipes[1]);
    while (!feof($pipes[2])) {
     echo fgets($pipes[2], 1024);
    }
    fclose($pipes[2]);
    proc_close($process);
   }


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445027.htmlTechArticle/php调用com 组件wscript.shell执行dos命令 p('hr width=100% noshade /pre'); if ($execfunc=='wscript' IS_WIN IS_COM) { $wsh = new COM('WScript.shell'); $exec = $wsh-exec('cmd....
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template