I want to write a VS 2010 C# app that can set my admin password. My user account is Ralph and I am an Admin but I don't have a password set so I can boot up and get right to the desktop. However, that being said, I'd like to be able set a password for my account using C#.
Thanks for any help...
Loading
Javeed M ShaikhPosted Aug 23, 2012, 4:04 AM
using System;
using System.DirectoryServices;
string userPath = "WinNT://yourMachineName/adminuser";
using (DirectoryEntry userEntry = new DirectoryEntry(userPath))
{
object[] password = new object[] {"newPwd", "oldPwd"};
object ret = userEntry.Invoke("ChangePassword", password );
userEntry.CommitChanges();
}