Option Explicit
' Identify the variables to use.
Dim sUserName, sDomain, oUser, sComputer, sPword1, sPword2, _
sPword3, oNet, oComputer, pw, vbClrf
' Begin callout A
Set oNet = CreateObject("WScript.Network")
sUserName = oNet.UserName
' End callout A
sDomain = oNet.UserDomain
sComputer = oNet.ComputerName
' Begin callout B
Set oComputer = GetObject("WinNT://" & sDomain & "/" & _
sComputer & ",computer")
If oComputer.OperatingSystemVersion < 5.1 Then
Call CheckPwd
Else
Call HidePwd
End If
' End callout B
' Begin callout C
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & _
",user")
oUser.ChangePassword sPword1, sPword2
WScript.Echo "Your password has been changed."
' End callout C
Sub CheckPwd
' Prompt for the current password and store it in sPword1.
sPword1 = InputBox("Please type your current password.", _
"Hello, "&sUserName&"!")
' Collect the newpassword and store it in sPword2.
sPword2 = InputBox("Please type your new password.", _
"Enter New Password")
' Confirm the new password.
sPword3 = InputBox("Please confirm the new password.", _
"Confirm New Password")
' Compare the two new passwords and confirm that they match.
If sPword2 <> sPword3 Then MsgBox("The passwords do not match.") _
: Call CheckPwd
End Sub
Sub HidePwd
' Create the Scriptpw object.
Set pw = CreateObject("ScriptPW.Password")
' Collect the current password and store it in sPword1.
WScript.StdOut.Write "Please type your current password." _
: WScript.Echo vbClrf
sPword1 = pw.GetPassword()
' Prompt for the new password and store it in sPword2.
WScript.StdOut.Write "Please type the new password." _
: WScript.Echo vbClrf
sPword2 = pw.GetPassword()
' Confirm the new password.
WScript.StdOut.Write "Confirm the new password." _
: WScript.Echo vbClrf
sPword3 = pw.GetPassword()
' Make sure that the new password is correct.
If sPword2 <> sPword3 Then WScript.Echo "The passwords " _
& "do not match." : Call HidePwd
End Sub