Bunch of useful WMI Functions in VB.Net

Also Check Out: My latest venture. http://loqly.me – a way for you to ask questions and get answers about local businesses around you. iTunes link: http://bit.ly/e5u4jv (only available in US for now)


Below is a copy-paste class with a lot of VB.Net functions which allow you to query your computer information using WMI queries. Hope it helps.

  • GetComputerInfo()
    Computer Information (OS, OS Version, Manufacturer, Computer Name, Windows Directory, Total RAM (in MB), Free RAM (in MB), Free Ram Raw, Total Ram Raw)
  • GetShares()
    List of all shares (Share Name, Share Path)
  • GetDrives()
    List of all local drives (Device ID, Used GB, Total GB, Provider Name, Description)
  • GetServices()
    List of local services (Name, Description)
  • GetNetworkInfo()
    List of all Network adapters (NIC Description, MAC Address, DHCP Enabled or not)
  • GetStartupPrograms()
    List of all Startup programs (Full path)
  • GetPrinters()
    List of local printers (Device ID)
  • GetRegistryInfo()
    Registry Maximum size and current size
  • GetPageFileInfo()
    Intial Page Size and Maximum Page file size.
  • GetVideoRamInfo()
    Video card Chip Type and Video Ram size
  • IsProcessRunning()
    Checks if a given process is running or not.

input.JPG WMI.vb

PS: Some people have been asking about the ImpersonateValidUser helper function that is missing in the WMI.vb class. Here is the function if you need it.

input.jpgImpersonateValidUser

Advertisements

11 thoughts on “Bunch of useful WMI Functions in VB.Net

  1. hello! i tried using your wmi.vb code but it doesnt work, the error is “format for xml is not declared” can help me how to fix it?.. thank you and more power!

  2. Try returning XML String instead of the default.
    RETURN_XMLSTRING instead of RETURN_DATASET and see what the function is returning.

    Also, be aware that to execute all the WMI queries, you should have correct priveleges on the machine. More often that not this is the reason why the quries fail, not because there is a bug in the query.

  3. hi,

    this is jashmine….

    the above wmi function is really good ,

    can u help me in getting the all installed hardware components list and installed software information in the system or remote system in vb.net(2005) ,

    advance thanks,
    regards

    jashmine

  4. hi! its me again! thanks for the comment but it doesnt work, i have another error “impersonateValidUser is not declared” kindly give me a code that just run without the xml format i think thats my big problem..ü

    thank you a lot!

  5. I would like to get a list of all the mac addresses (with VB.NET) of a particular manufacturer in a domain, local or subnet network. Let’s say, all Linksys mac address.

    Is there a way to do that. I undestand that each manufacturer uses unique codes in the MAC address that identifies their NIC cards.

    Thanks!

  6. I would like to get a list of all the mac addresses (with VB.NET) of a particular manufacturer in a domain, local or subnet network. Let’s say, all Linksys mac address.

    Is there a way to do that? I undestand that each manufacturer uses unique codes in the MAC address that identifies their NIC cards.

    Thanks!

  7. This was just what I was looking for. THe only problem was the missing function used by the code.
    I assume that it went something like this…
    Protected Function FormatForXML(ByVal Input As Object) As String
    Dim data As String = Input.ToString() ‘ cast the input to a string
    ‘replace those characters disallowed in XML documents
    data = data.Replace(“&”, “&”)
    data = data.Replace(“”””, “"”)
    data = data.Replace(“‘”, “'”)
    data = data.Replace(“”, “>”)
    Return data
    End Function

  8. Hi ,

    I tried the code but i’m unable to get list of local printers into a dropdownlist.Please help me if any body..its very urgent..in web application..

    Thanks & Regards,
    vijay

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s