使用c#创建windows本地用户帐号
来源:互联网 发布:卿烨科技 知乎 编辑:程序博客网 时间:2024/06/05 00:35
使用c#创建windows本地用户帐号
Using the Windows net command, it’s easy to create local Windows User Accounts. The syntax for the net command is:
net user [username] [password] /ADD
The following C# function takes in three parameters -- username, password and home directory.
using System.Diagnostics;
public void CreateLocalUser(string username, string password, string homedir)
{
if (!Directory.Exists(homedir))
Directory.CreateDirectory(homedir);
Process MyProc = new Process();
MyProc.StartInfo.WorkingDirectory = "C:/WINNT/SYSTEM32";
MyProc.StartInfo.FileName = "net.exe";
MyProc.StartInfo.UseShellExecute = false;
MyProc.StartInfo.RedirectStandardError = true;
MyProc.StartInfo.RedirectStandardInput = true;
MyProc.StartInfo.RedirectStandardOutput = true;
MyProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
MyProc.StartInfo.Arguments = @" user " + username + @" " + password + @" /ADD /ACTIVE:YES " +
@"/EXPIRES:NEVER /FULLNAME:" + username + @" /HOMEDIR:""" +
homedir + @""" /PASSWORDCHG:NO /PASSWORDREQ:YES";
MyProc.Start();
MyProc.WaitForExit();
MyProc.Close();
}
- 使用c#创建windows本地用户帐号
- 使用c#创建windows本地用户帐号
- 使用C#批量创建帐号
- 使用C#批量创建帐号
- 使用C#代码实现增加用户帐号
- 使用C#代码实现增加用户帐号
- 在Delphi中ADSI创建Windows用户帐号
- C# 创建 使用 本地数据库
- 文件服务器-快速创建用户帐号!
- NET C#创建WINDOWS系统用户
- 使用C#创建webservice本地调用方式
- 使用C#创建Windows服务
- Win2003批量创建域用户帐号
- Linux shell下创建用户帐号
- Day7 - useradd创建一个用户帐号
- Django1.7 创建超级用户帐号
- 创建本地用户脚本
- 用delphi增加/获得windows用户帐号
- 2006.05.07
- 一个简易的FTP客户端软件
- 网络数据包监视程序开发(十二)---Windows下启用IP路由选择
- 数制转换
- HAPPY!终于独立AC了一道DP的题。。
- 使用c#创建windows本地用户帐号
- The Standalone Programmer: Tips from the trenches(1)
- 一些值得收藏的网址
- STL概览-序列容器vector,deque,list(三)
- delphi中的快捷键大收集
- 2006.5.1-5.7完成了.
- SQL如何生成汉字列表
- 程序开发团队---危机篇
- .net三级联动不刷新效果