Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 5 - 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 
Moblin 
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

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Listing/Modifying Server Information with Visual Basic.NET and VBScript Using WMI - How to change your computer name using WMI


    (Page 5 of 5 )

    You can change your computer name using VB.NET and WMI as shown in the following:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
    As System.EventArgs) Handles Button1.Click
            Try
                Dim classInstance As New ManagementObject( _
                    "root\CIMV2", _
                    "Win32_ComputerSystem.Name='SERVER'", _
                    Nothing)
                Dim inParams As ManagementBaseObject = _
                    classInstance.GetMethodParameters("Rename")
                inParams("Name") = "server2" 'rename to
                inParams("Password") = "admin"
                inParams("UserName") = "administrator"
                Dim outParams As ManagementBaseObject = _
                    classInstance.InvokeMethod("Rename", inParams,
    Nothing)
                MessageBox.Show("ReturnValue: {0}", outParams
    ("ReturnValue"))
            Catch err As ManagementException
                MessageBox.Show("Error: " & err.Message)
            End Try
        End Sub

    Note that I am using “InvokeMethod” to execute a WMI method (in this case “Rename”) dynamically.  “inParams” (an object of ManagementBaseObject) is specifically used to pass parameters to the WMI method “Rename”.  It mainly contains the required information to penetrate through the authentication and authorization (username and password) of security, along with the new computer name.  We can get the result after executing the WMI method “Rename” into “outParams”.

    You can achieve the same result using the following VBScript code:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set objShare = objWMIService.Get("Win32_ComputerSystem.Name='SERVER'")
    Set objInParam = objShare.Methods_("Rename").inParameters.SpawnInstance_()
    objInParam.Properties_.Item("Name") =  "server2"
    objInParam.Properties_.Item("Password") =  "admin"
    objInParam.Properties_.Item("UserName") =  "administrator"
    Set objOutParams = objWMIService.ExecMethod("Win32_ComputerSystem.Name='SERVER'", "Rename", objInParam)
    Wscript.echo "ReturnValue: " & objOutParams.ReturnValue

    Summary

    You can further delve into the classes of WMI and design your own application to manage almost every important aspect of the Windows OS.  If you extend your skills to ASP.NET, then you can develop a web application which can manage your server information on the fly, without your presence in the office itself!  I think you can imagine the same, if you further extend it to the Pocket PC level!  Good luck.

    Anyway, once again, I must be thankful to all the readers who appreciated and encouraged me to further expand the series in a much more useful and efficient manner.  Thank you very much.

    Any comments, suggestions, bugs, errors, feedback etc. are highly appreciated at jag_chat@yahoo.com.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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

    VISUAL BASIC.NET ARTICLES

    - Movement and Player Statistics in a VB.NET T...
    - 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...





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