CONNECTING
For global admins
define("NAMECOMP", 'COMP1'); // COMP1 - name or ip of local or remote computer
$WMI= new COM ( 'winmgmts:{impersonationLevel=impersonate}//'. NAMECOMP.'/root/cimv2' );
For with login and password
$objLocator = new COM("WbemScripting.SWbemLocator");
$objService = $objLocator->ConnectServer(
'ComputerName', //name/ip remote/local comp
"root\cimv2",
'login', //login remote/local comp
'password', //password remote/local comp
"MS_409",
"ntlmdomain: YourDomain" //domain remote/local comp
);
GET INFORMATION
$CountCore=0;
foreach ($WMI->instancesof ( 'Win32_Processor' ) as $proc ) {
++$CountCore;
}
echo 'Count Core = ' . $CountCore;
add information of speed and socket processor
$CountCore=0;
foreach ($WMI->instancesof ( 'Win32_Processor' ) as $Processor) {
++$CountCore;
$Speed=$Processor->CurrentClockSpeed;
$Socket=$Processor->SocketDesignation;
}
echo 'count core = '.$CountCore;
echo 'speed = ' . $Speed. 'Mhz';
echo 'socket = '.$Socket;
get other information simple - just replace class for instancesof ('Win32_Processor')
Information of classes WMI
SEND COMMAND
if ((($_GET['Reboot']==1) OR ($_GET['Shutdown']==1))) {
define("NAMECOMP", 'COMP1');
$WMI= new COM('winmgmts:{impersonationLevel=impersonate,(Shutdown)}//'. NAMECOMP.'/root/cimv2');
foreach($WMI->instancesof('Win32_OperatingSystem') as $mp) {
if ($_GET['Reboot']==1) {
$mp->Reboot;
}
if ($_GET['Shutdown']==1) {
$mp->Shutdown;
}
}
Links:
WMI Isn't Working!
Component_Object_Model
Win32 Classes
For Yii Framework