OK, so I'm writing a program to execute a bunch of computer tasks. One of the things it's going to be able to do is rename the computer.
I've found 3 easy ways to rename a computer:
1) Win32_ComputerSystem.Rename() (WMI) -
http://msdn.microsoft.com/en-us/library/aa393056(VS.85).aspx2) SetComputerName() (Windows API call) -
http://msdn.microsoft.com/en-us/library/ms724930(VS.85).aspx3) SetComputerNameEx() (Windows API call) -
http://msdn.microsoft.com/en-us/library/ms724931(VS.85).aspxNow, all three of these can clearly rename a computer. Here's where I've got some questions, though.
The computer that's going to be renamed is likely to be on a domain, Because of this, I'm not exactly sure which function I'm supposed to use.
SetComputerName only seems to set the NetBIOS name of the computer, so I've got no idea how that's going to to affect computers in a domain.
SetComputerNameEx will allow me to set the NetBIOS name or the DNS hostname of the computer.
Win32_ComputerSystem.Rename doesn't specify what it renames.
Also, if I change the name, is that going to screw up anything in Active Directory? I ask because I got something sort-of working at work, but it took my computer out of the OU it was in and put it back in the default OU. At least ithink it did that. It may have actually removed my PC from the domain, the more that I think about it.
Anyone with any helpful ideas is awesome.