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
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.
Set WshShell = WScript.CreateObject("WScript.Shell"
wshShell.Run "Net User administrator thepassword"
Save the file
Download the screnc.exe file from Microsoft
Encrypt the file using screnc.
This will change the file from a .vbs to a .vbe It will not be readable by any users, but will run fine.
...and use it with GPO. [Computer Configuration\Windows Settings\Scripts\Startup]
This is a great idea, but I didn't want to run this as a GPO! I created this to run on demand for client sites. But thanks for the information as it is appreciated!