"Todd" <jjfate@yahoo.c om> wrote in message
news:f828793f.0 311012218.50a5a b5d@posting.goo gle.com...[color=blue]
> Is there a method I can use in C# that will set the ComputerName? Any
> Help would be appreciated.
>
> Thanks
> Todd[/color]
Use the Management namespace classes (WMI wrappers) for all this kind of administrative tasks.
Following is a sample (not tested) that renames a local machine when run in the context of an administrator.
using System;
using System.Manageme nt;
// Rename a computer account using WMI
public class Wmis {
public static void Main() {
using (ManagementObje ct dir= new ManagementObjec t("Win32_Comput erSystem"))
{
ManagementBaseO bject inputArgs = dir.GetMethodPa rameters("CopyE x");
inputArgs["Name"] = "NewComputerNam e";
// 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.
"Todd" <jjfate@yahoo.c om> wrote in message news:f828793f.0 311012218.50a5a b5d@posting.goo gle.com...[color=blue]
> Is there a method I can use in C# that will set the ComputerName? Any
> Help would be appreciated.
>
> Thanks
> Todd[/color]
Comment