sirbounty, can you modify so it takes the value from a txtbox as string?
TIA
Main Topics
Browse All TopicsI am building a small application that retrieves system information via WMI. My VBScript works fine, however, the VB.Net code does not execute. Further, I get an "Unspecified Error" when I try to trap the error to find out what it is. Below is the troublesome code:
**********************
Function getinfo()
On Error GoTo Errhand
Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Dim strComputer As String = txtServerName.Text
objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
colItems = objWMIService.ExecQuery("S
For Each objItem In colItems
MsgBox("Name: " & objItem.Name)
Next
Errhand:
MsgBox(Err.Number & " " & Err.Description)
End Function
**********************
I am referencing System.Management with Imports System.Management.
Can someone give me a bit of assistance with this?
Thanks,
IPT
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I put this in function.. hangs the app:
Function getinfo()
Dim objWMISearch As ManagementObjectSearcher
Dim colItems As ManagementObjectCollection
Dim objItem As ManagementObject
'Dim objWMI As ManagementScope = WMIConnect()
Dim strQuery = "Select * From Win32_ComputerSystem"
Dim objWMI As ManagementScope
objWMI = New ManagementScope("\\" & txtServerName.Text & "\root\cimv2")
objWMI.Connect()
Try
objWMISearch = New ManagementObjectSearcher(o
colItems = objWMISearch.Get
For Each objItem In colItems
Console.WriteLine(objItem.
Next
Catch
MessageBox.Show(Err.Descri
End Try
End Function
This worked for me - I started a new project to be sure that I wasn't missing something...perhaps trim your textbox?
In my FormLoad...
Dim strResults As String=GetInfo("Servername
The function...
Function GetInfo(ByVal strServer As String)
Dim strDetail As String
Dim objWMISearch As ManagementObjectSearcher
Dim colItems As ManagementObjectCollection
Dim objItem As ManagementObject
Dim objWMI As ManagementScope = New ManagementScope("\\" & strServer & "\root\cimv2")
Dim strQuery As String = "Select * From Win32_OperatingSystem"
Try
objWMI.Connect()
objWMISearch = New ManagementObjectSearcher(o
colItems = objWMISearch.Get
For Each objItem In colItems
strDetail=objItem.GetPrope
Next
Catch
MessageBox.Show(Err.Descri
strDetail=Nothing
End Try
Return strDetail
End Function
Business Accounts
Answer for Membership
by: sirbountyPosted on 2007-04-23 at 11:16:38ID: 18960376
Try this...
() jWMI.Path. ToString, strQuery) Caption") ption
Dim objWMISearch As ManagementObjectSearcher
Dim colItems As ManagementObjectCollection
Dim objItem As ManagementObject
Dim objWMI As ManagementScope=WMIConnect
Dim strQuery="Select * From Win32_ComputerSystem"
Try
objWMISearch=New ManagmentObjectSearcher(ob
colItems=objWMISearch.Get
For Each objItem in colItems
Console.WriteLine objItem.GetPropertyValue("
Next
Catch
Messagebox.Show(Err.Descri
End Try