SQLScholar
Programmer
hey all,
I know its possible in VBS but i want to do the same in vb.net (so no need for .net).
Any ideas how i can do this?
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
I know its possible in VBS but i want to do the same in vb.net (so no need for .net).
Code:
Dim objWMIService
Dim colItems
Dim objItem
Try
objWMIService = GetObject("winmgmts:\\" & Environ("COMPUTERNAME") & "\root\CIMV2")
colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
ComputerName = objItem.Name.ToString
Next
[code]
Now it errors on For Each objItem In colItems with an Unspecified error on the COM object. Now I have taken this from VBS and trying to implement it the same way. What am i doing wrong?
The VBS that works looks something like this
[code
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("localhost")
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "PC_Name," & objItem.Name
WScript.Echo "Domain," & objItem.Domain
WScript.Echo "PC_Manufacturer," & objItem.Manufacturer
WScript.Echo "PC_Model," & objItem.Model
WScript.Echo "PC_Mem," & objItem.TotalPhysicalMemory
Next
/SNIP
Any ideas how i can do this?
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------