I wan to create user account in a remote machine and set some credintial to it. i knew that we can use WMI to run batch file remotly on another machine .
is there a way to run batch file using c# code to create user name and passowrd remotly on another machine
Instead of using a batch file, it is possible to use the classes in System.DirectoryServices.
// you need to supply these parameters:
string domainName = "domain";
string computerName = "computer";
string userName = "name";
string password = "password";
var machineDirectory = new DirectoryEntry(@"WinNT://" + domainName + @"/" + computerName + ",computer");
var userEntry = machineDirectory.Children.Add(userName, "user");
userEntry.Invoke("SetPassword", password);
userEntry.CommitChanges();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.