Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5991049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:19:53+00:00 2026-05-22T23:19:53+00:00

Might someone be able to point me towards a conclusive resource to learn how

  • 0

Might someone be able to point me towards a conclusive resource to learn how to remotely change a computer name on a Windows Server 2008 machine using C#

I’ve looked at lots of sites for help and now in day two of my task and not really any closer (other than deciding WMI is pretty much my only option) Totally out of my normal skillset so I guess pretty much any info would be nice, but especially anything having to do with changing a computer name remotely. (this would occur right after I remotely spin up a virutal from an image…and yes, i realize a reboot will be required)

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:19:53+00:00Added an answer on May 22, 2026 at 11:19 pm

    Here is a nice link that discusses it in detail and also deals with active directory membership and machine naming in addition to the local machine name.
    http://derricksweng.blogspot.com/2009/04/programmatically-renaming-computer.html

    (Btw, should you have to deal with Active Directory naming, I would consider using the ComputerPrincipal class from the System.DirectoryServices.AccountManagement namespace vice anything from System.DirectoryServices namespace that was used in the blog post.)

    Tweaked code from the blog post (you will need to add a reference to System.Management to your project):

        public void RenameRemotePC(String oldName, String newName, String domain, NetworkCredential accountWithPermissions)
        {
            var remoteControlObject = new ManagementPath
                                          {
                                              ClassName = "Win32_ComputerSystem",
                                              Server = oldName,
                                              Path =
                                                  oldName + "\\root\\cimv2:Win32_ComputerSystem.Name='" + oldName + "'",
                                              NamespacePath = "\\\\" + oldName + "\\root\\cimv2"
                                          };
    
            var conn = new ConnectionOptions
                                         {
                                             Authentication = AuthenticationLevel.PacketPrivacy,
                                             Username = oldName + "\\" + accountWithPermissions.UserName,
                                             Password = accountWithPermissions.Password
                                         };
    
            var remoteScope = new ManagementScope(remoteControlObject, conn);
    
            var remoteSystem = new ManagementObject(remoteScope, remoteControlObject, null);
    
            ManagementBaseObject newRemoteSystemName = remoteSystem.GetMethodParameters("Rename");
            var methodOptions = new InvokeMethodOptions();
    
            newRemoteSystemName.SetPropertyValue("Name", newName);
            newRemoteSystemName.SetPropertyValue("UserName", accountWithPermissions.UserName);
            newRemoteSystemName.SetPropertyValue("Password", accountWithPermissions.Password);
    
            methodOptions.Timeout = new TimeSpan(0, 10, 0);
            ManagementBaseObject outParams = remoteSystem.InvokeMethod("Rename", newRemoteSystemName, null);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hoping someone might be able to assist me, or point me in the right
I have a slight issue that someone might be able to point me in
I'm having some strange drawing artefacts that I'm hoping someone might be able to
I might be losing the plot, but I hope someone can point me in
I realise this is a bit vague but hoping someone might be able to
Hoping someone might be able to shine a little light on this for me
I wondered if someone might have some insight into this. jqGrid is quite happy
I was hoping someone might help with a function that given two parameters: @param
Can someone give me some info/background info on how I might go about writing
I'm concerned that this might be working on an NP-Complete problem. I'm hoping someone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.