用下面的一段代码可以向Windows添加用户,可是如何使新加的用户密码不会过期?
Func _Add_LocalUser($sNewUsrName, $sNewUsrPass, $sNewUsrFull = "", $sNewUsrDesc = "")
;;;;;检查用户名是否合法
If StringStripWS($sNewUsrName,8) = "" Then
MsgBox(16,"Error","Invalid User Name !")
Return False
EndIf
;;;;;;;检测用户是否已存在!
TrayTip("Working Hard....","Checking User ....",5,1)
$isWorking = True
$strComputer="."
$colLocalComputer = ObjGet("WinNT://" & $strComputer)
If @error Then
MsgBox(16,"Error","Can Not Get The Object(WinNT://) !"
$isWorking = False
Return False
EndIf
Dim $user[1]=["user"]
$colLocalComputer.Filter = $user
For $objuser In $colLocalComputer
If $objuser.Name = $sNewUsrName Then
TrayTip("Error","User "&$objuser.Name&" Already Exist !",3,3)
MsgBox(16,"Error","User "&$objuser.Name&" Already Exist !")
$isWorking = False
Return
EndIf
Next
;;;;;;;添加用户
TrayTip("Working Hard....","Adding User "&$sNewUsrName&" ....",10,1)
Local $colLocalComputer, $objUser
$colLocalComputer = ObjGet("WinNT://" & @ComputerName)
If @error Then
TrayTip("Error","Can Not Get The Object(WinNT://) !",5,3)
MsgBox(16,"Error","Can Not Get The Object(WinNT://) !")
$isWorking = False
Return False
EndIf
$objUser = $colLocalComputer.Create ("user", $sNewUsrName)
$objUser.SetPassword ($sNewUsrPass)
$objUser.Put ("Fullname", $sNewUsrFull)
$objUser.Put ("Description", $sNewUsrDesc)
$objUser.SetInfo
TrayTip("Working Hard....","User "&$user&" Added !",3,1)
$isWorking = False
;TrayTip("Working Hard....","",1)
Return True
EndFunc
[ 本帖最后由 hehui 于 2008-9-16 10:36 编辑 ] |