SitePoint Sponsor

User Tag List

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

    Question How to display wmi query results in 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

    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 code it generates uses the console as the output. I am still new to this level of 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.

    Imports System
    Imports System.Management
    Imports System.Windows.Forms
    Namespace WMISample
       Public Class MyWMIQuery
           Public Overloads Shared Function Main() As Integer
                   Dim searcher As New ManagementObjectSearcher( _
                       "root\CIMV2", _
                       "SELECT * FROM Win32_ComputerSystem") 
                   For Each queryObj As ManagementObject in searcher.Get()
                       Console.WriteLine("Win32_ComputerSystem instance")
                       Console.WriteLine("Manufacturer: {0}", queryObj("Manufacturer"))
                       Console.WriteLine("Model: {0}", queryObj("Model"))
                       Console.WriteLine("Name: {0}", queryObj("Name"))
                       Console.WriteLine("TotalPhysicalMemory: {0}", queryObj("TotalPhysicalMemory"))
               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 web page.

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

    Thanks in advance,

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

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2006
    0 Post(s)
    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.


Posting Permissions

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