Reputation: 948
I want to retrieve the number of processors running in a remote server, from my server. To do so, I check the information using this command line :
C:\Users\Administrator>psexec -accepteula \\remote_computer_name -u remote_computer_name\admin -p my_password cmd /C "set number_of_processors"
And it returns me the result I wanted :
But when I'm trying to retrive the same result using it in PHP script, it says that the access is denied.
PsExec v1.98 - Execute processes remotely Copyright (C) 2001-2010 Mark Russinovich Sysinternals - www.sysinternals.com
Access is denied.
Connecting to remote_computer_name... Starting PsExec service on remote_computer_name... Could not start PsExec service on remote_computer_name: Connecting to remote_computer_name... Starting PsExec service on remote_computer_name...
Here is my PHP script :
<?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>";
}
?>
I am using the same script on another pair of server, and it is working really well. What did I miss ?
Upvotes: 1
Views: 1389
Reputation: 948
Finally found the answer ! I only add the -h arguments to my command line.
-h If the target system is Vista or higher, has the process run with the account's elevated token, if available.
Upvotes: 0