Monday, 12 March 2018

change admin password script

This VB script will change the local administrator password of a computer remotely by hostname. Tested on Windows XP, 2003 & Vista.


'==========================================================================
'ChangeAdminPassword.vbs
'Created by Timothy Bourne
'http://www.imric.co.uk
'Last Modified: 10th October 2007
'==========================================================================
'This VBscript will change the local administrator password of a computer 
'remotely by hostname.
'==========================================================================

Option Explicit
Dim strComputer, strPassword
Dim objUser

'Set the password.
strPassword = "Pa$$w0rd."

'Input box for the user the enter the remote hostname.
strComputer = InputBox("Enter Computer name:", "Computer Name")

'Get the Administator user account and set the password.
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator, user")
objUser.SetPassword(strPassword)
objUser.SetInfo

'Set the Administrator account as enabled.
objUser.AccountDisabled = False
objUser.SetInfo

'Echo out that the Administrator password is reset.
WScript.Echo "The administrator password on " & strComputer & " has been changed."

No comments:

Post a comment