COMPOUND
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 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 about 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;
getting other information is easy - just replace the class for instances ('Win32_Processor')
WMI Class Information
SEND TEAM
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; } }
References:
WMI does not work!
Component_Object_Model
Win32 classes
For Yii Framework
Evgeniy Tkachenko
source share