The company I work for has a lot of computers and all of them had different local Admin passwords.
I created this script to set all local admin passwords! All you need to do is enter the names of your hosts into a .txt file.Then drop the .txt file onto the script.
———-COPY EVERYTHING BELOW THIS LINE for the Script———-
'Change local admin passwords – just drop a txt file with a list of computers name onto the script
' Created by Chey Harden on 12.3.07
On Error Resume Next
Const HKLM = &H80000002
Const ForReading = 1
strPass = "YOUR PASSWORD HERE"
strKeyPath = "Software"
strKeyBluWav = "Software\BluWav"
BluWavExists = 0
strValueName = "AdminPassword"
strValue2 = 1
strChangePass = 0
Set objArgs = WScript.Arguments
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(objArgs(0), ForReading)
strComputers = objFile.ReadAll
objFile.Close
arrComputers = Split(strComputers, vbCrLf)
For Each strComputer In arrComputers
Set objShell = CreateObject("Wscript.Shell")
Set objScriptExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer)
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
oReg.EnumKey HKLM, strKeyPath, arrSubKeys
If InStr(objScriptExec.StdOut.ReadAll, "Reply") > 0 Then
Err.Clear
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator, user")
If Err.Number Then
WScript.Echo strComputer & ": Incorrect Username"
Err.Clear
Else
FindKey()
'WScript.Echo BluWavExists
CreateKey()
ReadRegString()
If strChangePass = 1 Then
objUser.SetPassword strPass
objUser.SetInfo
strChangePass = 0
Else
'WScript.Echo "Password Already Set!"
End If
'WScript.Echo " " & strComputer & " – Password successfully changed"
End If
Else
WScript.Echo strComputer & " : Could not find host!"
End If
Next
Function FindKey()
For Each subkey In arrSubKeys
'WScript.Echo subkey ' For Trouble shooting
If subkey = "BluWav" Then
BluWavExists = 1
End If
Next
End Function
Function CreateKey()
If BluWavExists = 0 Then
oReg.CreateKey HKLM,strKeyBluWav
End If
End Function
Function ReadRegString()
oReg.GetStringValue HKLM,strKeyBluWav,strValueName,strValue
'WScript.Echo strValue
If strValue = 1 Then
'WScript.Echo "Key Written"
Else
WriteRegString()
End If
End Function
Function WriteRegString()
oReg.SetStringValue HKLM,strKeyBluWav,strValueName,strValue2
strChangePass = 1
End Function
———-COPY EVERYTHING ABOVE THIS LINE for the Script———-
PLEASE MAKE SURE NO WORD WRAPPING IS HAPPENING IN YOUR SCRIPT!!!
1. Create a .txt file with a list of the computers.
2. Make sure to be an admin on the target machines.
3. Change this line to reflect your password: strPass = "YOUR PASSWORD HERE"
4. Drag and drop the .txt file onto the script.
This information is provided "AS IS" with no warranties expressed or implied.