Changing all the local admin passwords

Various scripts and codes for a variety of applications.

Changing all the local admin passwords

Postby Egaladeist on Sun Dec 16, 2007 7:29 am

Originally Posted by cemetric: here

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.
User avatar
Egaladeist
Site Admin
 
Posts: 270
Joined: Fri Dec 14, 2007 1:12 pm

Return to Scripts and Coding Resource

Who is online

Users browsing this forum: No registered users and 1 guest

cron