欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用C#在本地創(chuàng)建一個(gè)Windows帳戶(DOS命令)

 更新時(shí)間:2007年03月09日 00:00:00   作者:  
其它方法見.用C#在本地創(chuàng)建一個(gè)Windows帳戶(DirectoryServices) 
http://yaosansi.com/blog/article.asp?id=917   

在WinForm下該程序可寫成:   (已測(cè)試通過,需要以Administrator身份運(yùn)行)    

  using   System;    
  namespace   eg    
  {    
  class     test    
  {    
  static     void     Main()    
  {    

  //聲明一個(gè)程序信息類    
  System.Diagnostics.ProcessStartInfo     Info     =     new     System.Diagnostics.ProcessStartInfo();    

  //設(shè)置外部程序名    
  Info.FileName     =     "net.exe";    

  //設(shè)置外部程序的啟動(dòng)參數(shù)(命令行參數(shù))為test.txt    
  Info.Arguments     =     "   user   abc   /add";    

  //設(shè)置外部程序工作目錄為     D:\    
  Info.WorkingDirectory     =     "D:\\";    

  //聲明一個(gè)程序類    
  System.Diagnostics.Process     Proc     ;    

  try    
  {    
  //    
  //啟動(dòng)外部程序    
  //    
  Proc     =     System.Diagnostics.Process.Start(Info);    
  }    
  catch(System.ComponentModel.Win32Exception     e)    
  {    
  Console.WriteLine("系統(tǒng)找不到指定的程序文件。\r{0}",     e);    
  return;    
  }    
  }    
  }    
  }    

  注:ASPNET帳戶隸屬于Users組,Users組對(duì)計(jì)算機(jī)沒有完全控制權(quán),涉及到系統(tǒng)管理的一些命令就無(wú)法使用了;至于為什么在進(jìn)程中看不到是因?yàn)樵摋l語(yǔ)句是以命令行運(yùn)行的,要看效果的話只能在CMD下:   net   user   查看  





  添加管理員:    
  System.Diagnostics.Process.Start("CMD.exe","/c   net   user   admin   123456   /add");    
  System.Diagnostics.Process.Start("CMD.exe","/c   net   localgroup   administrators   admin   /add");    

  修改admin的密碼為250:    
  System.Diagnostics.Process.Start("CMD.exe","/c   net   user   admin   250   ");    
  刪除管理員:    
  System.Diagnostics.Process.Start("CMD.exe","/c   net   user   admin   /del");  




在CMD下就可以完全操作了,可以直接調(diào)用命令行工具如   System.Diagnostics.Process.Start("net   user   ...");    

  net   user   用法    

  用于增加/創(chuàng)建/改動(dòng)用戶帳戶    

  語(yǔ)法:    

  net   user   <username>   [password   or   *]   [/add]   [options]   [/domain]    
  net   user   <username]   /delete   /domain    

  username   帳號(hào)名    
  password   分配或改變密碼    
  *   密碼提示    
  /domain   在一個(gè)域中執(zhí)行    
  /add   創(chuàng)建一個(gè)帳號(hào)    
  /delete   刪除一個(gè)帳戶    
  /active:[yes   or   no]   激活或停止一個(gè)帳號(hào)    
  /comment:"<text>"   加入描述性說明    
  /counterycode.nnn   nnn   是系統(tǒng)編碼.   0為系統(tǒng)缺省值    
  /expires:<date   or   never>   帳號(hào)到期時(shí)間.格式:月,日,年或日,月,年(格式由國(guó)家代碼決定)    
  /fullname:"<name>"   帳號(hào)全名    
  /homedir:<path>   用戶主目錄路徑    
  /passwordchg:[yes   or   no]   設(shè)置用戶能否更改密碼    
  /passwordreq:[yes   or   no]   設(shè)置用戶是否需要密碼    
  /profilepath:<path>   設(shè)置環(huán)境文件路徑    
  /scriptpath:<path>   登錄腳本路徑    
  /times:<times   or   all>   用戶可以登錄的小時(shí)數(shù)    
  /usercomment:"<text>"   帳號(hào)說明信息    
  /workstations:<machine   names>   允許登錄的用戶名.   *   表示所有用戶 

相關(guān)文章

最新評(píng)論