如何在 Windows 中使用 Ruby 获取已安装应用程序的列表?
我知道使用 wmi 查询 WIN32_product 可以读取已安装应用程序的列表,但该列表与控制面板下的添加/删除程序列表不同。 另一种方法是读取 Windows 注册表中的 Software\Microsoft\Windows\CurrentVersion\Uninstall ?
我正在使用以下几行 ruby 代码来执行此操作,但它不起作用
对于此示例,我正在寻找名为 Branding 的软件(当我在 Windows 7 PC 中进行 regedit 时它会显示)
Win32::Registry::HKEY_LOCAL_MACHINE.open('Software\Microsoft\Windows\CurrentVersion\Uninstall\Branding') do |reg|
reg_typ, reg_val = reg.read('')
return reg_val
end
运行后出现错误消息这段代码
win32/registry.rb:528:in `open': The system cannot find
the file specified. (Win32::Registry::Error)
from win32/registry.rb:608:in `open'
这段代码有什么问题?
I know that using wmi query WIN32_product
one can read the list of installed applications but the list is different from add/remove program list under control panel.
Another approach would be to read Software\Microsoft\Windows\CurrentVersion\Uninstall
in windows registry?
I am using the following few lines of ruby code to do that but it is not working
For this example I am looking for a software by the name of Branding (it shows when I go thru regedit in my windows 7 PC)
Win32::Registry::HKEY_LOCAL_MACHINE.open('Software\Microsoft\Windows\CurrentVersion\Uninstall\Branding') do |reg|
reg_typ, reg_val = reg.read('')
return reg_val
end
Error Message after running this piece of code
win32/registry.rb:528:in `open': The system cannot find
the file specified. (Win32::Registry::Error)
from win32/registry.rb:608:in `open'
What is wrong with this piece of code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
但要注意:“Software\Wow6432Node\Windows\CurrentVersion\Uninstall”
Though beware of: 'Software\Wow6432Node\Windows\CurrentVersion\Uninstall'
查看此链接,了解如何操作的说明注册表适用于 64 位平台
Check out this link for an explanation of how the registry works on 64 bit platforms