I found another one in my scripts folder (yes I have a huge collection) ...
It works slightly different:
- Code: Select all
strPassword = "P@ssw0rD"
Const InputFile = "x:\path\listofcomputers.txt"
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(InputFile, ForReading)
strComputers = objFile.ReadAll
objFile.Close
arrComputers = Split(strComputers, vbCrLf)
On Error Resume Next
For Each strComputer In arrComputers
' Ping the computer
Set objShell = CreateObject("Wscript.Shell")
Set objScriptExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer)
If InStr(objScriptExec.StdOut.ReadAll, "Reply") > 0 Then
' User name
' change it to another name if necessary
Err.Clear
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator, user")
If Err.Number Then
WScript.Echo " " & strComputer & " - ERROR: User name not found"
Err.Clear
Else
objUser.SetPassword strPassword
objUser.SetInfo
WScript.Echo " " & strComputer & " - Password successfully changed"
End If
Else
WScript.Echo " " & strComputer & " - ERROR: not responding"
End If
Next
This script sends an echo request to the computer before it tries to change the password ... you could combine it with the other script if you like.
.C.
