Home >php教程 >php手册 >php调用com 组件wscript.shell执行dos命令

php调用com 组件wscript.shell执行dos命令

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 11:22:301824browse

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


');<br>  if ($execfunc=='wscript' && IS_WIN && IS_COM) {<br>   $wsh = new COM('WScript.shell');<br>   $exec = $wsh->exec('cmd.exe /c '.$command);<br>   $stdout = $exec->StdOut();<br>   $stroutput = $stdout->ReadAll();<br>   echo $stroutput;<br>  } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {<br>   $descriptorspec = array(<br>      0 => array('pipe', 'r'),<br>      1 => array('pipe', 'w'),<br>      2 => array('pipe', 'w')<br>   );<br>   $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);<br>   if (is_resource($process)) {<br>    fwrite($pipes[0], $command."rn");<br>    fwrite($pipes[0], "exitrn");<br>    fclose($pipes[0]);<br>    while (!feof($pipes[1])) {<br>     echo fgets($pipes[1], 1024);<br>    }<br>    fclose($pipes[1]);<br>    while (!feof($pipes[2])) {<br>     echo fgets($pipes[2], 1024);<br>    }<br>    fclose($pipes[2]);<br>    proc_close($process);<br>   }	<br>
	
Statement:
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
Previous article:php 表单验证代码Next article:php mysql 数据库类