Create a Windows account locally (DOS command) _c# tutorial with C #
Source: Internet
Author: User
See other methods. Create a Windows account locally with C # (DirectoryServices)
http://yaosansi.com/blog/article.asp?id=917
Under WinForm The program can be written as: (tested through, need to run as Administrator)
Using System;
namespace eg
{
Class Test
{
static void Main ()
{
Declaring a program information class
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo ();
Set External program name
Info.filename = "Net.exe";
Set the external program's startup parameters (command-line arguments) to Test.txt
info.arguments = "User Abc/add";
Set external program working directory for D:\
Info.workingdirectory = "d:\\";
Declaring a program class
System.Diagnostics.Process Proc;
Try
{
//
Start an external program
//
Proc = System.Diagnostics.Process.Start (Info);
}
catch (System.ComponentModel.Win32Exception e)
{
Console.WriteLine ("The system cannot find the specified program file. \r{0} ", E);
Return
}
}
}
}
Note: The ASPNET account is subordinate to the Users group, and the Users group does not have full control over the computer, and some commands that involve system administration are not available; As to why the statement is not visible in the process because it is run on the command line, see the effect only under CMD: NET user view
Add Administrator:
System.Diagnostics.Process.Start ("CMD.exe", "/C net user admin 123456/add");
System.Diagnostics.Process.Start ("CMD.exe", "/C net localgroup Administrators Admin/add");
The password to modify admin is 250:
System.Diagnostics.Process.Start ("CMD.exe", "/C net user admin 250");
To remove an administrator:
System.Diagnostics.Process.Start ("CMD.exe", "/C net user Admin/del");
Under CMD can be completely manipulated, you can directly invoke command-line tools such as System.Diagnostics.Process.Start ("NET user ...");
NET user usage
Use to add/create/change user accounts
Grammar:
NET user <username> [password or *] [/add] [options] [/domain]
NET user <username]/delete/domain
Username account Name
Password assign or change a password
* Password hint
/domain executes in a domain
/ADD Create an account
/delete Delete an account
/active:[yes or no] activates or stops an account
/comment: "<text>" Add descriptive notes
/COUNTERYCODE.NNN nnn is a system code. 0 is the system default value
/expires:<date or never> account expiration time. Format: Month, day, year or day, month, year (format determined by country code)
/fullname: "<name>" account name
/homedir:<path> User Home directory path
/passwordchg:[yes or No] Sets whether the user can change the password
/passwordreq:[yes or No] sets whether the user needs a password
/profilepath:<path> Setting Environment file path
/scriptpath:<path> Logon Script path
/times:<times or all> the number of hours a user can log on
/usercomment: "<text>" account description information
/workstations:<machine names> The name of the user who is allowed to log on. * Represents all Users
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.