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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remotely changing local Admin user/pass XPPro

Status
Not open for further replies.

ATLMatt

Technical User
Jun 18, 2007
94
US
I'm trying to find a script that will change the user name and password for the local administrator account on a bunch of PCs at several of my remote locations.

My servers are Windows Server 2003, the PCs are XP Pro, and I am thinking of using the current GPO to launch the script to make the change when users log in. I am open to any other suggestions as well.

I know in server 2000 you could pass some arguments to Cusrmgr.exe to make the change, but I don't know of anything like that for 2003. Thanks for any advice you can give me!
 
This will change the administrator password...not sure how you would change the name of the administrator account.

Code:
Option Explicit
Dim strFile
Dim objFSO, objTS, strComputer

StrFile = "C:\computers.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFile) Then
	Set objTS = objFSO.OpenTextFile(strFile)
	Do Until objTS.AtEndOfStream
		strComputer = objTS.ReadLine
		
		'do something with strComputer
		If TestPing(strComputer) Then
		
			On Error Resume Next
			Dim objAdmin
			Set objAdmin = GetObject("WinNT:\\" & strComputer & "\Administrator,user")
			
			If Err = 0 Then
				objAdmin.SetPassword "P@ssw0rd!"
				objAdmin.SetInfo
			Else
				WScript.Echo strComputer & " skipped: " & _
				 Err.Description
			End If
			On Error GoTo 0
			
		End If
		
	Loop
End If

objTS.Close
WScript.Echo "Complete"

Function TestPing(sName)
	Dim cPingResults, oPingResult
	Verbose " Pinging " & sName
	Set cPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery("SELECT * FROM Win32_PinStatus WHERE Address = '" & sName & "'")
	For Each oPingResult In cPingResults
		If oPingResult.StatusCode = 0 Then
			TestPing = True
		Else
			TestPing = False
		End If
	Next
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top