/php Calling COM components Wscript.Shell executing DOS commands
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);
}
http://www.bkjia.com/PHPjc/445027.html www.bkjia.com true http://www.bkjia.com/PHPjc/445027.html techarticle /php Call COM component Wscript.Shell execute DOS command P (' hr width=100% noshade/pre '); {$wsh = = ' WScript ' Is_win is_com COM (' Wscript.Shell '); $exec = $wsh-exec (' cmd ... .