hello world

VBS修改本机的账号密码

 On Error Resume Next 

strComputer = "." 
Set WshShell = WScript.CreateObject("WScript.Shell") 

'Query Admin Members 
Set colGroups = GetObject("WinNT://" & strComputer) 
colGroups.Filter = Array("group") 
For Each objGroup In colGroups 
'check the administrators local group members.. 
If (InStr(1,objGroup.Name,"Administrators",1) >0) Then 
For Each objUser in objGroup.Members 
strUSER=strUSER &vbCrLf& objuser.class &"="& objUser.name 
next 
End If 
Next

sUser=InputBox("请输入您要修改的账户","修改账户","zhaojianlu")
Set objUser = GetObject("WinNT://" & strComputer & "/" & Chr(34) & sUser & Chr(34)) 
sPass=InputBox("请输入您要修改的密码","修改密码","123456")
objUser.SetPassword sPass 
objUser.Setinfo 

If Err <> 0 Then 
'write eventlog 
call logit ("1","Admin Password Change: Failed " & Err & vbCrLf&Err.Description _ 
&vbCrLf&Err.Source &vbCrLf& strUSER) 
MsgBox "密码修改失败,请确认您有管理员权限。"
Else 
call logit ("0","Admin Password Change: Successfull") 
MsgBox "密码修改成功"
End if 


'******************************* 
Function logit(strStatus,strDescription) 
WshShell.LogEvent strStatus,strDescription 
End Function

   欢迎加入QQ技术群聊:70539804

posted @ 2015-09-08 15:13  浩天四哥  阅读(943)  评论(0编辑  收藏  举报