dimanche 22 février 2015

Path to all of the installed programs with PHP

Is it possible to get the full path to the installed programs on my Windows OS with PHP?


Thanks to this awesome post on Stackoverflow, this is what the code looks like:



<?php
// if error: Fatal error: Class 'COM' not found add in php.ini
// extension=php_com_dotnet.dll
// http://ift.tt/1EjPkRw

define('HKEY_LOCAL_MACHINE', 0x80000002);
$computer = 'Awesome-NB'; //name of the station / pc
$reg = new COM("winmgmts:{impersonationLevel=impersonate}!\\\\$computer\\root\\default:StdRegProv");

$key_path = 'Software\Microsoft\Windows\CurrentVersion\Uninstall'; // this line will get all installed software

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

foreach($sub_keys as $sub_key){
print_r($sub_keys);
}
?>


I get a list. But I want the full path to the program, x64 and x86.


Aucun commentaire:

Enregistrer un commentaire