Sign in to follow this  
Followers 0
gulthaw

Enable local admin and changing the password

1 post in this topic

#1 ·  Posted (edited)

Hi,

I wanted to contribute with an script i had to create for work.

Since it was based on a script found in these forums (http://www.autoitscript.com/forum/index.ph...l+administrator) I want to give my two cents :P

$strComputer = @ComputerName
$user = @UserName
$dirTmp = "\\server\folder"
$CadArxiu = $dirtmp & "\file.txt"

$arxiu = FileOpen($CadArxiu, 1)

Local $colUsers, $sTmp, $Array[1] = ["user"]
$colUsers = ObjGet("WinNT://" & @ComputerName)

If IsObj($colUsers) Then
    $colUsers.Filter = $Array
    For $objUser In $colUsers
        if $objUser.Name = "Administrador" Then
            ;Account disabled?
            If $objUser.AccountDisabled Then
                MsgBox(0,"Tittle","Account disabled")
                $objUser.AccountDisabled = False
            EndIf
            $objUser.SetPassword("newpassadmin")
            $objUser.setInfo
            FileWriteLine($arxiu, $strComputer)
        EndIf
    Next
EndIf   

FileClose($CadArxiu)

This scripts checks if the local admin user is enabled, if not it will enable it (i'm not sure if this phrase is right, sorry my english :S ) and changes the password to "newpassadmin".

After that, adds a line to the file.txt located in \\server\folder so we can check what machines have changed the local admin password.

Hope it helps :(

NOTE (*edit*): The script is currently not working in Windows Vista business; no matter if the user who runs it is local admin or not. Working on it :idea:

Edited by gulthaw

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0