Results 1 to 2 of 2

Thread: change computer name and join domain

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    138

    change computer name and join domain

    hi gurus

    can this be done in VB.net, I would like to read a text file with a buncg of computer names, change the names and after that remove from one domain and join the same compter to a different domain without having to reboot the computer in between.

    if this is possible where do I start looking.

    Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: change computer name and join domain

    You can do this using WMI in the .NET Framework.

    Add a reference to System.Management and System.Management.Instrumentation and import the namespaces. Then...
    vb.net Code:
    1. Dim managementObj as new ManagementObject("root\\CIMV2", "Win32_ComputerSystem.Name='" & _
    2. Environment.MachineName & "'", Nothing)
    3. Dim parameter as ManagementBaseObject = managementObj.GetMethodParameters("Rename") _
    4. parameter["Name"] =  "NEWCOMPUTERNAMEHERE"
    5. Dim outParams as ManagementBaseObject = managementObj.InvokeMethod("Rename", inParams, null)
    This should rename the computer. Does this work for you?

    Joining a new domain is a different story. The computer name change will not take affect until the machine is rebooted.

Posting Permissions

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



Click Here to Expand Forum to Full Width