Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset local admin password on 2000 workstations!

Status
Not open for further replies.

TheMisio

Technical User
Sep 26, 2005
229
BE
Hi All,

What is the best way to reset local administrator passwords on 2000 workstations?
Is there a way to reset password of users in Local Administrators Group via script?
All workstations belong to a Windows 2003 domain. No SMS or any other management toll.

Regards,

Michael
 
Adrian, problem is that will change it for a single PC not 2000.

So you would need to ping each machine and create a dynamic array or read the machine host names or IP from a text file. [as below]. I find IP the easiest as you can do it in excel fairly quick.

Code:
On Error Resume Next
Dim f, objPing
Dim strNextLine, strComputer
Dim machine, objStatus
Dim objUser
Dim objDictionary : Set objDictionary = CreateObject("Scripting.Dictionary")
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objTextFile : Set objTextFile = objFSO.OpenTextFile("c:\backup\ip.txt", 1) 'Path to your file containing IP addresses

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const Data_Path = "C:\"
Const fileName = "ping.csv" 'Path to your log file e.g C:\ping.txt or .csv

'Logging
'If Not objFSO.FileExists(Data_Path & filename) Then 				'If log file does not exist
'Set f = objFSO.OpenTextFile(Data_Path & fileName,2, True) 		'Create it
If objFSO.FileExists(Data_Path & filename) Then 'If log file does exist
	objFSO.DeleteFile(Data_Path & filename)		'Delete the File
Else
Set f = objFSO.OpenTextFile(Data_Path & fileName,2, True) 'Create the file and write to it
'Set f = fso.OpenTextFile(Data_Path & fileName,8) 				'File exists append to the log file
End If 

'Read each line of file containing the IP addresses
Do Until objTextFile.AtEndOfStream 
 strNextLine = objTextFile.Readline
 strComputer = split(strNextLine)
For Each machine In strComputer
  Set objPing = GetObject("winmgmts:")._
      ExecQuery("select * from Win32_PingStatus where address = '"_
      & machine & "'")
  For Each objStatus In objPing
      If IsNull(objStatus.StatusCode) Or objStatus.StatusCode<> 0 Then
          WScript.Echo("machine " & machine & " is not reachable")
		  Failed
      Else
          WScript.Echo("reply from " & machine)
		  Success
      End If
  Next
Next
Loop

Function Success
	Set objUser = GetObject("WinNT://" & machine & "/Administrator, user")
			objUser.SetPassword ""
			objUser.SetInfo
	f.WriteLine VbCrLf & machine & " Responded."
End Function

Function Failed
	f.WriteLine VbCrLf & machine & " did not respond."
End Function
 
I assume you were looking at the code exert on the page which is just the bit that does the actual job, the full script reads the computer names from a text file and will do however many.


Adrian Paris

Paris Engineering Ltd

Google search of just tech forums & articles
(very useful, honest!)
 
Amazing what you can find on the vendors support sites these days...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top