‎01-06-2015 01:07 PM - last edited on ‎06-30-2023 03:34 PM by ErikT
Looks up the name of the Local Administrator and resets the password.
Rem: You need to add the password as a parameter.
Rem: If you do not add a password parameter, the password is default set to: !NewCompl3xP@ssword!
Rem: Copy the code below and save it as Reset_Local_Admin_Password.vbs at the {PackageShare}\Scripts folder
On Error Resume Next
strComputer = "."
Set oShell = CreateObject("WScript.Shell")
sUser = "Administrator"
sPwd = "!NewCompl3xP@ssword!"
Set Arg = WScript.Arguments
If Arg.Count > 0 Then
sPwd = Arg(0) 'Pass the password as parameter to the script
End if
'Get the administrator name
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount Where LocalAccount = True")
For Each objItem in colItems
sidAdmin = objItem.SID
if trim(right(sidAdmin, 3)="500") and trim(left(sidAdmin,9)="S-1-5-21-") then
'Echo = echo & "Name: " & objItem.Name & vbcrlf
'Echo = echo & "SID: " & sidAdmin
sUser = objItem.Name
Set oUser = GetObject("WinNT://" & strComputer & "/" & sUser)
' Set the password
oUser.SetPassword sPwd
oUser.Setinfo
exit for
end if
Next
‎06-03-2015 09:22 PM
‎03-10-2015 11:34 AM
‎07-24-2019 04:22 AM
Bert.D wrote:
No it is not.
To make it more secure, you could add an decryption method to the script and pass the password encrypted.
In the end, the script will still be readable by everyone who has access to the share where the file resides.
‎07-26-2019 07:30 PM
TaherMD wrote:Bert.D wrote:
No it is not.
To make it more secure, you could add an decryption method to the script and pass the password encrypted.
In the end, the script will still be readable by everyone who has access to the share where the file resides.
Hi, Could you please share how we could achieve this. (Sending an encrypted password and then decrypting it at the workstation.
Thanks.
‎03-09-2015 12:02 AM
‎03-04-2015 03:39 PM
strComputer = "."
sUser = "YourUser"
sPwd = "!NewCompl3xP@ssword!"
Set objUser = GetObject("WinNT://" & strComputer & "/" & sUser & ", user" )
objUser.SetPassword sPwd
objUser.SetInfo
‎02-20-2015 01:02 PM
‎02-16-2015 05:56 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now