【问题标题】:PSEXEC access denied when using PHP使用 PHP 时 PSEXEC 访问被拒绝
【发布时间】: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


    【解决方案1】:

    终于找到答案了!我只将 -h 参数添加到我的命令行中。

    -h 如果目标系统是Vista或更高版本,有进程 使用帐户的提升令牌(如果可用)运行。

    【讨论】:

      猜你喜欢
      • 2010-10-24
      • 1970-01-01
      • 1970-01-01
      • 2010-11-29
      • 2010-09-26
      • 2016-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多