ProAnswers.org

How do you read NT registry info with PHP?

How do you read NT registry info with PHP?

// Example to read the subkeys of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft (tested on PHP 5)

// See http://msdn2.microsoft.com/en-us/library/aa392722.aspx for methods

// See http://www.php.net/manual/en/ref.com.php

define('HKEY_LOCAL_MACHINE', 0x80000002);

$computer = '.';

$reg = new COM("winmgmts:{impersonationLevel=impersonate}!\\\\$computer\\root\\default:StdRegProv");

 

$key_path = 'SOFTWARE\Microsoft';

$sub_keys = new VARIANT();

$reg->EnumKey(HKEY_LOCAL_MACHINE, $key_path, $sub_keys);

 

foreach($sub_keys as $sub_key){

echo "$sub_key

";

}

?>