VB6 Get System Model

Hello Experts,

I am using VB6 and I am trying to get the system model #. Similar to http://www.freevbcode.com/ShowCode.asp?ID=4571 but for VB6.

Thoughts?
triphenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Martin LissOlder than dirtCommented:
As you've shown in the URL and some research by me shows that that's possible in VB.Net but I don't believe it's possible in VB6.
triphenAuthor Commented:
I am looking real hard, it looks like it's possible. I just someone to point me in the right direction...
Martin LissOlder than dirtCommented:
it looks like it's possible
If you can tell me why you think that, maybe I can help you look.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Martin LissOlder than dirtCommented:
This is a modification of something I found on the web.

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem In colItems
     Debug.Print "System Name: " & objItem.Name
     Debug.Print "Manufacturer: " & objItem.Manufacturer
     Debug.Print "Model: " & objItem.Model
Next

Open in new window

triphenAuthor Commented:
Set objWMIService = GetObject("winmgmts:\\ComputerName\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem In colItems
     Debug.Print "System Name: " & objItem.Name
     Debug.Print "Manufacturer: " & objItem.Manufacturer
     Debug.Print "Model: " & objItem.Model
Next

Open in new window


Produces error:   Compile error: Variable not defined

On: objWMIService
Martin LissOlder than dirtCommented:
You can either do

Dim objWMIService

or comment out Option Explicit
Martin LissOlder than dirtCommented:
This is better

Dim objWMIService
Dim colItems
Dim objItem
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem In colItems
     Debug.Print "System Name: " & objItem.Name
     Debug.Print "Manufacturer: " & objItem.Manufacturer
     Debug.Print "Model: " & objItem.Model
Next

Set objWMIService = Nothing
Set colItems = Nothing

Open in new window

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
triphenAuthor Commented:
Got it!

  Dim info As Object
    Dim cpus_query As String
    Dim cpus_results As Object

    cpus_query = "SELECT * FROM Win32_ComputerSystem"
    Set cpus_results = _
        GetObject("Winmgmts:").ExecQuery(cpus_query)
   For Each info In cpus_results

     MsgBox (info.Model)

Open in new window

Martin LissOlder than dirtCommented:
The source for the above was this article.
Martin LissOlder than dirtCommented:
Mine works to so I hope your kind enough to accept my answer.
Martin LissOlder than dirtCommented:
Thanks.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014
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
Visual Basic Classic

From novice to tech pro — start learning today.