Page 1 of 1 1
Topic Options
#174510 - 2007-03-06 03:28 PM change local admin password
rsifre Offline
Fresh Scripter

Registered: 2007-02-06
Posts: 6
Loc: FL, Pinellas
I am trying to find a way to change the local admin password on workstations. I have a vbs that does it, but I rather use kix. This is the code for the vbs:

sNewPassword = "password"
Set oWshNet = CreateObject("WScript.Network")
sComputer = oWshNet.ComputerName
sAdminName = GetAdministratorName

On Error Resume Next
Set oUser = GetObject("WinNT://" & sComputer & "/" & sAdminName & ",user")
oUser.SetPassword sNewPassword
oUser.SetInfo
On Error Goto 0


Function GetAdministratorName()

Dim sUserSID, oWshNetwork, oUserAccount

Set oWshNetwork = CreateObject("WScript.Network")
Set oUserAccounts = GetObject( _
"winmgmts://" & oWshNetwork.ComputerName & "/root/cimv2") _
.ExecQuery("Select Name, SID from Win32_UserAccount" _
& " WHERE Domain = '" & oWshNetwork.ComputerName & "'")

On Error Resume Next
For Each oUserAccount In oUserAccounts
If Left(oUserAccount.SID, 9) = "S-1-5-21-" And _
Right(oUserAccount.SID, 4) = "-500" Then
GetAdministratorName = oUserAccount.Name
Exit For
End if
Next
End Function


Is there any known script for this or can someone translate this vbs to kix?

Thanks a lot
_________________________
I am a newbie to kix

Top
#174514 - 2007-03-06 04:20 PM Re: change local admin password [Re: rsifre]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
Translation:
 Code:
$sNewPassword = "password"
$sComputer = @WKSTA
$sAdminName = GetAdministratorName

$oUser = GetObject("WinNT://" + $sComputer + "/" + $sAdminName + ",user")
$oUser.SetPassword($sNewPassword)
$oUser.SetInfo

Function GetAdministratorName()
  Dim $sUserSID, $oWshNetwork, $oUserAccount
  $oWshNetwork = CreateObject("WScript.Network")
  $oUserAccounts = GetObject("winmgmts://" + $oWshNetwork.ComputerName + "/root/cimv2").ExecQuery("Select Name, SID from Win32_UserAccount" + " WHERE Domain = '" + $oWshNetwork.ComputerName + "'")
  For Each $oUserAccount In $oUserAccounts
    If Left($oUserAccount.SID, 9) = "S-1-5-21-" And Right($oUserAccount.SID, 4) = "-500"
      $GetAdministratorName = $oUserAccount.Name
    EndIf
  Next
EndFunction

Top
#174523 - 2007-03-06 05:51 PM Re: change local admin password [Re: Arend_]
rsifre Offline
Fresh Scripter

Registered: 2007-02-06
Posts: 6
Loc: FL, Pinellas
Thanks a lot!!!

By the way, is there a kix script that will change the local admin account name/username?
_________________________
I am a newbie to kix

Top
#174544 - 2007-03-06 11:06 PM Re: change local admin password [Re: rsifre]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
changing the administrator password can also be done via GPO (Group Policy).
Top
#174547 - 2007-03-07 12:04 AM Re: change local admin password [Re: Witto]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Howard Bullock's RenameAdmin.exe utility.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#174593 - 2007-03-08 09:56 PM Re: change local admin password [Re: Les]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Unfortumately I changed ISP's (Comcast->Verizon) and no longer have an active web site from which to download my programs.

Edited by Howard Bullock (2007-03-08 09:56 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.059 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org