【发布时间】:2018-02-07 19:53:56
【问题描述】:
我正在尝试从我的 Java 程序中获取 Windows 10 中安装的所有应用程序的列表。 我尝试了以下方法:
Runtime.getRuntime().exec("Get-WmiObject -class Win32_Product | Select-Object -Property Name");
我得到:
Cannot run program "Get-WmiObject": CreateProcess error=2
我也试过了:
Process p = Runtime.getRuntime().exec("Get-ItemProperty HKLM:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize");
结果相似。
最后,我尝试使用库“win32”,但它只返回一些已安装程序的名称。
我需要的结果与在 powershell 中执行以下命令时得到的结果相同:
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |选择对象 DisplayName、DisplayVersion、Publisher、InstallDate | Format-Table –AutoSize
我一直在寻找 stackoverflow 中的其他问题,但没有一个能给我解决方案。我需要在每个磁盘单元中搜索(而不仅仅是在 C: 中)。谁能告诉我一个可能的解决方案?
谢谢。
【问题讨论】:
标签: java windows winapi registry winreg