lonewolf217 Posted August 15, 2009 Share Posted August 15, 2009 I have two php scripts, one which queries WMI on the root\cimv2 namespace which works without a problem on remote systems. I have another I am trying to use to query the root\default namespace to parse the registry and this one isn't working properly Does anyone have any examples of how to do something like this ? Google has been rather sparce on how to do this. I would do this in powershell but unfortunetly the remote machines are across multiple domains and authentication can't be scripted in powershell This is the error I cannot get around [15-Aug-2009 00:25:58] PHP Fatal error: Call to a member function EnumKey() on a non-object in D:\EXKB\testfiles\wmireg.php on line 25 <?php //initialize the object $hostname = "machine"; $strUser = "admin"; $strPass = "password"; try { $rpc = new COM('WbemScripting.winmgmts:{impersonationLevel=impersonate}'); //$wshShell = new COM("winmgmts:{impersonationLevel=impersonate}//{$hostname}/root/default:StdRegProv"); $wmi = $rpc->ConnectServer($hostname, 'Root\default:StdRegProv',$strUser,$strPass); } catch(Exception $e) { echo "Failure to connect: " . $e; } define('HKLM',0x80000002); $keyPaths = array("SOFTWARE\Microsoft\Exchange","SOFTWARE\Wow6432Node\Microsoft"); $keys = new VARIANT(array()); try { foreach($keyPaths as $keyPath) { echo "attempting path: " . $keyPath."<br>"; $wmikey = $wmi->EnumKey(HKLM,$keyPath,&$keys) or die("ERROR"); //THIS IS LINE 25 echo $wmikey."<br>"; foreach($keys as $subkey) { print_r($subkey); } } } catch(Exception $e) { echo $e; } ?> Quote Link to comment Share on other sites More sharing options...
Markh789 Posted August 15, 2009 Share Posted August 15, 2009 Call to a member function EnumKey() on a non-object This means your trying to run something from something that is not an object. E.G, A class. I have not used this before, though is $wmi an object? Quote Link to comment Share on other sites More sharing options...
trq Posted August 15, 2009 Share Posted August 15, 2009 I would say your call to ConnectServer() isn't working then, no idea why though. Id hate to be scripting anything on windows. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.