Billy Bob said:
Thanks for that idea, but I'd rather do it C# so anyone that has to
maintain my code in the future wount have to bother with that.
I've got ...
ManagementClass mc = new ManagementClass("Win32_ComputerSystem");
ManagementObjectCollection moc = mc.GetInstances();
According to MSDN
http://msdn2.microsoft.com/en-us/library/aa393056.aspx
there is a rename method but I'm not sure how to get to it.
But you can do it in C#, Start is a method of the System.Diagnostics
namespace class Process, all you need is a few lines of code using this.
But if you want to go WMI you need to call the Rename function, here is
something that might get you started.
using (ManagementObject dir= new ManagementObject("Win32_ComputerSystem"))
{
ManagementBaseObject inputArgs = dir.GetMethodParameters("Rename");
inputArgs["Name"] = "newComputerName";
// Other input args are UserName and Password.
// If not specified the current user security context is used to execute
the command.
// See WMI sdk docs or MSDN for details.
ManagementBaseObject outParams = dir.InvokeMethod("Rename", inputArgs,
null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret == 0)
...// success
else
..
Willy.