レジストリにアクセスするのはPowershellに任せている。
<?php // IE $ie_cmd = 'reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer" /v "svcVersion"'; $r = shell_exec($ie_cmd); $ie_version = '不明'; if (preg_match('/REG_SZ\s+(.*)/', $r, $m)){ $ie_version = $m[1]; } printf("IE: %s\n", $ie_version); $csv = ""; $output_file = 'apps_output.csv'; $cmd=<<<EOF Get-ItemProperty HKLM:Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion | export-csv -NoTypeInformation -Encoding Default Get-ItemProperty HKLM:Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion | export-csv -NoTypeInformation -Encoding Default Get-AppxPackage | Sort-Object Name | Select PackageFullName, Version | export-csv -NoTypeInformation -Encoding Default Get-WmiObject -Class Win32_Product -ComputerName . | Select-Object Name, Version | Export-Csv -Encoding Default EOF; foreach (explode("\n", trim($cmd)) as $c){ $c = trim($c); shell_exec(sprintf('powershell.exe "%s %s"', $c, $output_file)); $csv .= "\r\n---------------------\r\n".file_get_contents($output_file); } file_put_contents($output_file, $csv); $data = array(); if (($handle = fopen($output_file, "r"))) { while (($d = fgetcsv($handle, 1000, ","))) { $data[] = $d; } } // この$dataを調べると良い感じで。