SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast CyberNet99's Avatar
    Join Date
    Oct 2003
    Location
    Ottawa, Canada
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to display wmi query results in vb.net web page

    I am trying to figure out how to be able to query a remote server using wmi and then display the results in an aspx web page using vb.net.

    I have downloaded and am using the WMI Code Creator to browse and determine which WMI queries I want to use, but all of the vb.net code it generates uses the console as the output. I am still new to this level of vb.net web development and do not know how I can modify this code to display the wmi query results on a web page.

    Here is a sample bit of WMI code that the tool generates to get the operating system, make and model of the remote system.

    Code:
    Imports System
    Imports System.Management
    Imports System.Windows.Forms
    Namespace WMISample
       Public Class MyWMIQuery
           Public Overloads Shared Function Main() As Integer
               Try
                   Dim searcher As New ManagementObjectSearcher( _
                       "root\CIMV2", _
                       "SELECT * FROM Win32_ComputerSystem") 
                   For Each queryObj As ManagementObject in searcher.Get()
                       Console.WriteLine("-----------------------------------")
                       Console.WriteLine("Win32_ComputerSystem instance")
                       Console.WriteLine("-----------------------------------")
                       Console.WriteLine("Manufacturer: {0}", queryObj("Manufacturer"))
                       Console.WriteLine("Model: {0}", queryObj("Model"))
                       Console.WriteLine("Name: {0}", queryObj("Name"))
                       Console.WriteLine("TotalPhysicalMemory: {0}", queryObj("TotalPhysicalMemory"))
                   Next
               Catch err As ManagementException
                   MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
               End Try
           End Function
       End Class
    End Namespace

    I've been searching online with no solid examples on how to integrate wmi calls into a vb.net web page.

    If anyone has any pointers or can assist in any way I would be very grateful for the help.

    Thanks in advance,

    Tim
    Last edited by CyberNet99; Apr 29, 2009 at 08:30.
    Cheers, Tim

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Console.Write(string arg) the string arg is whatever you want to appear in the console.

    So instead of using Console.Write(string arg) you can assign those same strings to Literal1.Text = string arg or you can populate a list with lstWhatever.Items.Add(string arg)

    You're simply manipulating string data returned by WMI.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •