SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Listing/Modifying Server Information with ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Listing/Modifying Server Information with Visual Basic.NET and VBScript Using WMI
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2005-12-13

    Table of Contents:
  • Listing/Modifying Server Information with Visual Basic.NET and VBScript Using WMI
  • Listing minimum server information using WMI
  • How to retrieve all user account information using WMI
  • How to retrieve all group information along with account information using WMI
  • How to change your computer name using WMI

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Listing/Modifying Server Information with Visual Basic.NET and VBScript Using WMI - How to retrieve all group information along with account information using WMI


    (Page 4 of 5 )

    The following VB.NET code would give you the information on all user groups available (whether or not the user group is part of a domain).  It also includes user account information.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                Dim searcher As New ManagementObjectSearcher( _
                       "root\CIMV2", _
                       "SELECT * FROM Win32_AccountSID")
                Dim dt As DataTable = globals.getStructure()
                Dim en As ManagementObjectEnumerator =
    searcher.Get.GetEnumerator
                While en.MoveNext
                    Dim queryObj As ManagementObject = en.Current
                    globals.addRow(dt, "User: ", queryObj("Element"))
                End While
                dt.AcceptChanges()
                Me.DataGrid1.DataSource = dt
            Catch err As ManagementException
                MessageBox.Show("An error occurred while querying for
    WMI data: " & err.Message)
            End Try
        End Sub

    You can achieve the same result by using VBScript code as follows:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_AccountSID",,48)
    For Each objItem in colItems
        Wscript.Echo "Element: " & objItem.Element
    Next

    One should note that I used different WMI classes and properties for different scenarios.  You can get the full list of classes along with their properties and other documentation online at MSDN online.  Hundreds of classes exist in WMI to fetch even the most in-depth information about your server.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · I hope you enjoyed this article on how to retrieve information from your server....
     

    VISUAL BASIC.NET ARTICLES

    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway