Maison >développement back-end >tutoriel php >php调用com 组件wscript.shell执行dos命令_PHP教程
/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> <p align="left"></p><div style="display:none;"> <span id="url" itemprop="url">http://www.bkjia.com/PHPjc/445027.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/445027.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">/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....</span> </div> <div class="art_confoot"></div>