Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get the Computer Description using WMI? 2

Status
Not open for further replies.

Darrenzo

Technical User
May 29, 2003
35
0
0
GB
Does anyone know the values required to pull out the 'computer description' in XP using a WMI script?
If there are any free tools anyone can recommend to help interigate the WMI database that would also be helpful.

Cheers

Darren
 
Download scriptomatic from MS:


It gives the following for getting the Computer Description from WMI:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
Wscript.Echo "Description: " & objItem.Description
Next
 
Thanks for your reply Chipk,

I did'nt explain very well, but its the Computer Description that you would see when browsing the network that I'm looking for (set in My Computer Properties -> Computer Name). Sorry, I did'nt make that clear in my original post.

Any ideas?
 
oh, wow, I was way off.

I can't seem to find that in the WMI repository. You could pull it straight out of the registry from this value using "regread" in vbs:

HKLM\System\CurrentControlSet\Services\lanmanserver\Parameters\srvcomment

If I get a second to test that out, I'll give you the exact lines of code.
 
Aw shucks, I just remembered something, with the regread and regwrite functions, I don't think you can use on remote computers, and I'm not sure if that's what you're attempting, but here's the code anyway:

Dim objShell
Set objShell = CreateObject("Wscript.Shell")
RegKey = "HKLM\System\currentControlSet\Services\lanmanserver\Parameters\"
PCDesc = objShell.RegRead(RegKey & "srvcomment")
Wscript.Echo PCDesc

You could always use a vbs to call the reg.exe program from the Resource Kit, which CAN query remote registries. If you need help with that, let me know.
 
Will this work for you?
Code:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
    Wscript.Echo "Description: " & objItem.Description
Next
 
Good call, Guitarzan. I didn't think to look under the Win32_OperatingSystem.
 
Thats just what I'm looking for!! Thanks Guitarzan!!
Thanks also to Chipk for your input, most appreciated!


 
Your welcome and thanks for the star.

If you haven't checked out the Scriptomatic Tool that chipk directed you to yet, I highly recommend it... it's a great way to wade through the TONS of WMI classes and objects available to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top