I want to get a list of my installed programs.
I know how it works with powershell : Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize .
But I want it with php. Now I have this:
<?php
$Wshshell= new COM('WScript.Shell');
$data = $Wshshell->regRead('HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall');
?>
I get this error: Source: WshShell.RegRead
Description: Unable to open registry key "HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" for reading
Here is a project that allows PHP to obtain and interact dynamically with a real Powershell. Get it here: https://github.com/merlinthemagic/MTS
After downloading you would simply use the following code:
$shellObj = \MTS\Factories::getDevices()->getLocalHost()->getShell('powershell');
$strCmd = 'Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate';
$return1 = $shellObj->exeCmd($strCmd);
echo $return1;// list of all programs
You can issue any command you like against the $shellObj, the environment is maintained throughout the life of the PHP script.