Need help converting WMI System.Management code in VB.NET

I am trying to get a LIST of applications from a specific PC' sregistry.  I have code pieced from other snippets and I feel I am pretty close; however, I am still gettng an error.  I use a single FORM and TEXTBOX to spit out the results.  I keep gettign this ERROR:  File name or class name not found during Automation operation.

Imports System.Management
 
 
Public Function InstalledApps() As String
 
        Dim strPcName As String = "wkstn-bmz7741.nc.com"
        Dim strRegValue As Object
        Dim strKey As Object
        Dim intRegTest As Object
        Dim strBaseKey As Object
        Dim strValue As Object
        Dim arSubKeys()
        Dim iErr As Object
        Dim objWMIService As System.Management.ManagementObject
 
        Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
 
        objWMIService = GetObject("winmgmts:\\" & strPcName, "Root\CIMV2")
        strRegValue = GetObject("winmgmts://" & strPcName & "/root/default:StdRegProv")
 
        strBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
        intRegTest = strRegValue.EnumKey(HKLM, strBaseKey, arSubKeys)
 
        For Each strKey In arSubKeys
            intRegTest = strRegValue.GetStringValue(HKLM, strBaseKey & strKey, "DisplayName", strValue)
            If intRegTest <> 0 Then
                strRegValue.GetStringValue(HKLM, strBaseKey & strKey, "QuietDisplayName", strValue)
            End If
            If strValue <> "" Then
                InstalledApps = InstalledApps & strValue & ","
            End If
        Next
 
        TextBox1.Text = InstalledApps
 
    End Function

Open in new window

afsanchez001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

grayeCommented:
If you're doing this from VB.Net, I'd suggest that you use the "native" registry class (rather than WMI's registry routines).
            Dim reg_hklm, key, subkey As RegistryKey  
 
            reg_hklm = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, RemotePC)
            key = reg_hklm.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall", False)
            If Not IsNothing(key) Then
                For Each temp In key.GetSubKeyNames()
                    subkey = key.OpenSubKey(temp, False)
                    If Not IsNothing(subkey.GetValue("DisplayName")) Then
			debug.Writeline(subkey.GetValue("DisplayName").ToString)
                        subkey.Close()
                    End If
                Next
                key.Close()
            End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
afsanchez001Author Commented:
Thanks graye!  I'll give it a try and report back to you.  -Anthony
0
afsanchez001Author Commented:
Worked like a charm, THANKS!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.