Saturday, June 23, 2012

Script to change password on multiple users



Set objNet = CreateObject("WScript.NetWork")
strComputer = objNet.ComputerName
strUser1  = "administrator"
strUser2  = "user1"
strUser3  = "user2"
strUser4  = "user3"
strUser5  = "guest"
strPassword = InputBox("Enter Password")
If strPassword = "" Then
MsgBox("User cancelled or Blank Password! Nothing changed!"), vbInformation
Else
On Error Resume Next
For i=1 To 5
Select Case i
Case 1
strUser = strUser1
Case 2
strUser = strUser2
Case 3
strUser = strUser3
Case 4
strUser = strUser4
Case 5
strUser = strUser5
End  Select
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ", user")
objUser.SetPassword strPassword
objUser.SetInfo
Next
If Err.Number <> 0 Then
MsgBox "Error: An Incorrect User Name Was Found!", vbCritical
Err.Clear
Else
MsgBox "The Password Has Been Changed For all Users", vbInformation
End If
End If

No comments: