Script to change the local administrators password on 60 Servers

Ok what I would like is a vbs script to read a text file containing a list of the servers, read a text file containing a list of passwords, for the script to take each server name connect to it and change the password to the one in the text file and then to connect to the next server in the list and to change the password to the one on the next line down on the password list.  On completion to report 60 successfull password changes without the need to reboot the server.  Is this possible?
The script will be run as a domain admin so will have sufficient privileges to make the change

Needed quite urgently hence the points, oh mixture of NT4, W2k & 2003
Who is Participating?
johnreckConnect With a Mentor Commented:
Dim fso
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set objArgs = WScript.Arguments.Unnamed
 InputFile = "C:\input.txt"
 MyDate = Replace(Date, "/", "-")
 OutputFile = "C:\output-" & mydate & ".txt"

         If fso.FileExists(InputFile) Then
             Set txtStreamIn = fso.OpenTextFile(InputFile)
             Set txtStreamOut = fso.OpenTextFile(OutputFile, 2, True)
             Do While Not (txtStreamIn.AtEndOfStream)
                 Dim s
                 Dim lst
                 s = txtStreamIn.ReadLine
                 lst = Split(s) ' returns an array
                 MsgBox lst(0)
              MsgBox lst(1)
                 strcomputer = lst(0)
                 password = lst(1)
                 'strComputer = txtStreamIn.ReadLine
                 chpw strComputer, password
             WScript.Echo "Input file doesnt exist."
         End if
 Sub printOut (data)
     WScript.Echo data
     txtStreamOut.writeline data
 End Sub 'printOut
 Sub chpw (computer,password)    
     Set objUser = GetObject("WinNT://" & computer & "/administrator, user")
     printOut "changing the password on " & computer & " to " & password & " successful"
     objUser.SetPassword password
 End Sub 'chpw

the input.txt file each line should be
computername password

leave 1 space in between computername and password

Also objuser  change administrator to the local administrator account if it is not called administrator

also must be run by some one with admin rights.
rsivanandanConnect With a Mentor Commented:
Very Simple for a single password;

Go to and get the pspasswd utility.

Then just run it this way;

Make a text file, lets call it 'file' and put in your machine names one by one into it.  

pspasswd @file Administrator <newpassword>

Run it with domain administrator privilege and you are done. Just create a batch file and keep it for future.

Batch File:

pspasswd @file Administrator %1

Save the above into 'change.bat' and invoke it as 'change.bat <newpassword>'

For multiple passwords, you'll have to create a batch file to create a loop and read the password from the other file;

cochAuthor Commented:
Thanks, but I really want different passwords on each machine, so how would I create the loop?
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

cochAuthor Commented:
Thanks thats exactly what I wanted, however I have copied the above and it errored initially on the line Set objArgs = WScript.Arguments.Unnamed so I removed the word Unamed (?) and it ran and then it errored on the line usage so i removed this (?) and even though a file exists called input.txt at root of C: it says Input file doesn't exist?

Can you help?
delete this line totaly  Set objArgs = WScript.Arguments.Unnamed

also are you running XP?
also try a different file name
cochAuthor Commented:
deleted the line completely and used a different filr name data.txt and it ran a bit further, is shows the first server name and password in the message box then errors at line 36 character 6  the line Set objUser
do all the computers have the same local admin account name as administrator also the text file should be

computer password
computer password

with one space if it failes at Set objUser  it might be the admin account name is wrong.
cochAuthor Commented:
Thanks for your responses, however I am now going to use CUsrMgr part of Resource kit in Windows 2000 for this
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.