Jump to content
Sign in to follow this  

Enable local admin and changing the password

Recommended Posts



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
            FileWriteLine($arxiu, $strComputer)


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