I am trying to put together some VB code that will query WMI at Win32_Product
for installations of Java and then return its version number.
For example:
Java data in programs and features:
Name - Java 8 Update 91 (64-bit)
Version - 8.0.910.14
I would want this query to return the Version information so that I could populate a textbox/label/listbox with it.
Here is what I have so far:
Dim strComputer = "."
Dim objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Dim colSoftware = objWMIService.ExecQuery("Select * from Win32_Product Where Name ='Java 8 Update 91 (64-bit)'")
For Each objItem In colSoftware
ListBox1.Text = ("Version: " & objItem.Version)
Next
This code doesn't show any errors in Visual Studio, but when I try to run it, it doesn't populate my listbox.
Any ideas?
PS: I am not much of a developer I am working on this to participate in a hackathon at work. So please excuse if this doesn't make much sense.