douxin8749
2013-05-22 09:51
浏览 130
已采纳

WMI查询使用PHP获取远程IP信息

$obj = new COM ( 'winmgmts://localhost/root/CIMV2' );
$fso = new COM ( "Scripting.FileSystemObject" );    
$wmi_computersystem    =    $obj->ExecQuery("Select * from Win32_ComputerSystem");
$wmi_bios              =    $obj->ExecQuery("Select * from Win32_BIOS");
$processor             =    $obj->ExecQuery("Select * from Win32_Processor");
$PhysicalMemory        =    $obj->ExecQuery("Select * from Win32_PhysicalMemory");
$BaseBoard             =    $obj->ExecQuery("Select * from Win32_BaseBoard"); 
$LogicalDisk           =    $obj->ExecQuery("Select * from Win32_LogicalDisk");


foreach ( $wmi_computersystem as $wmi_call )
{
    $model = $wmi_call->Model;
}

foreach ( $wmi_bios as $wmi_call )
{
    $serial = $wmi_call->SerialNumber;
    $bios_version = $wmi_call->SMBIOSBIOSVersion;
}

i have above code to get the localhost information.and it works well. My question is, To get the remote machine info,where should i put user credentials(username,password of domain administrator)?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douhuan4699 2013-05-22 10:12
    已采纳

    You need to create an intermediary WbemScripting.SWbemLocator object, something like this:

    $loc = new COM( "WbemScripting.SWbemLocator" );
    $obj = $loc->ConnectServer( "hostname", "rootcimv2", "user", "password" );
    
    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题