使用c#创建windows本地用户帐号
2005-12-01 11:39
701 查看
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] /ADDThe 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#代码实现增加 windows 用户帐号
- AD:使用C#批量创建帐号
- 使用 Kubernetes 在 Windows 10 上创建本地集群
- 使用C#代码实现增加用户帐号
- 在Delphi中ADSI创建Windows用户帐号
- centOs创建git服务器和windows创建本地git的使用步骤
- 如何:使用 Windows 窗体 TextBox 控件创建密码文本框 .NET Framework 2.0 其他版本 密码框是一种 Windows 窗体文本框,它在用户键入字符串时显示占位符。 创
- 关于Windows 2008 IIS无法使用虚拟目录密码作为用户 administrator 在本地登录到...解决方案
- C# 创建 使用 本地数据库
- C#创建windows服务搭配定时器Timer使用实例
- 使用C# impersonation进行windows帐号的校验
- Windows 8 Metro应用中使用C#连接SQLite及创建数据库,数据表的增删改查
- 使用C#代码实现增加用户帐号
- 初识GihHub,创建仓库,使用GitHub for Windows 同步本地代码文件,创建分支
- 转 :AD:使用C#批量创建帐号 http://www.itepub.net
- 使用C#代码实现增加用户帐号
- oracle安装后使用SQLPLUS命令创建表空间和修改用户默认表空间windows平台
- InstallShield 2012 Spring新功能试用(10): 支持在安装过程创建预定义的多个Windows用户帐号和组