Use the DirectoryServices library - something like:
DirectoryEntry objLocalAdmins = new
DirectoryEntry("WinNT://MACHINE/Administrators,group");
object oUserPath = "WinNT://MACHINE/Username";
objLocalAdmins.Invoke("Add", new object[] {oUserPath});
Check out the docs for the DirectoryEntry object, and IADSGroup etc in MSDN.
Can also be used to add domain users, use domain in stead of machinename for
the userpath.
Arild
"Ching-Lung" <cl******@hotmail.com> wrote in message
news:04****************************@phx.gbl...
Hi,
Is there any way to add a new user to local admin group
via C#?
Please advice, thanks!
-CL