【发布时间】:2017-02-14 12:44:56
【问题描述】:
我想从我的服务器中检索远程服务器中运行的处理器数量。 为此,我使用以下命令行检查信息:
C:\Users\Administrator>psexec -accepteula \\remote_computer_name -u remote_computer_name\admin -p my_password cmd /C "set number_of_processors"
它会返回我想要的结果:
但是当我尝试在 PHP 脚本中使用它来检索相同的结果时,它说访问被拒绝。
PsExec v1.98 - 远程执行进程 版权所有 (C) 2001-2010 Mark Russinovich Sysinternals - www.sysinternals.com
访问被拒绝。
正在连接到 remote_computer_name... 正在启动 PsExec 远程计算机名称上的服务...无法启动 PsExec 服务 remote_computer_name:正在连接到 remote_computer_name...正在启动 PsExec remote_computer_name 上的服务...
这是我的 PHP 脚本:
<?php
function executeCmd($cmd,$params,$return)
{
//$resTable = array();
$resInt = -1;
exec("$cmd $params",$resTable,$resInt);
//$resTable=shell_exec($cmd $params);
//print_r($resTable);
if($return == 40)// return associative table
return $resTable;
if($return == 41)// return int
return $resInt;
}
$cmd = "psexec";
$params = " -accepteula \\\\remote_computer_name -u remote_computer_name\\admin -p password cmd /C \"set number_of_processors\" 2>&1";
//$res = system($cmd,$params,40);
$res = executeCmd($cmd,$params,40);
for($i=0;$i<count($res);$i++)
{
print_r($res[$i]);
echo "</br>";
}
?>
我在另一对服务器上使用相同的脚本,它运行得非常好。我错过了什么?
【问题讨论】:
标签: php remote-server access-denied psexec