Jump to content

Windows Password Checker


usmma
 Share

Recommended Posts

Hello, I am new to the Autoit forums. I work at a military college that needs to keeps students from installing unauthorized software on there pc's. To save me allot of time I was wondering if anyone knew of a script that could check to see if the Admin password has changed? I am pretty sure this can be done with autoit but like i said to save me time I figure i would ask the experts in here. If you have seen one or can writ one for me I would greatly appreciate it. Thanks!

Link to comment
Share on other sites

  • Developers

They should only be able to change the admin password when they have Administrator level access to the PC.

Its pretty simple to verify the password of the Administrator using this script:

RunAsWait("Administrator",@ComputerName,"test",0,@comspec & " /c echo .",@SystemDir,@SW_HIDE)
If @error then Msgbox(0,"Administrtor password changed","Administrtor password changed")

This is a script to reset the Administrators Name and Password correct:

$AdminUsername = "Administrator"
$AdminPassword = "StayOff"
;
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc"); Install a custom error handler
; Get current Admin account
$Admin = GetAdministratorName(@ComputerName)
ConsoleWrite('Current Administrator accountname = ' & $Admin & @LF)
; Rename User
If $Admin <> $AdminUsername Then
    $NewUser = $AdminUsername
    $oUser = ObjGet("WinNT://" & @ComputerName & "/" & $Admin & ",user")
    $oComputer = ObjGet("WinNT://" & @ComputerName)
    $oNewUser = $oComputer.MoveHere($oUser.ADsPath, $NewUser)
; check it rename was successful
    $Admin = GetAdministratorName(@ComputerName)
    ConsoleWrite('New Administrator accountname = ' & $Admin & @LF)
EndIf
; Check/Set Password
RunAsWait($AdminUsername, @ComputerName, $AdminPassword, 0, @ComSpec & " /c echo .", @SystemDir, @SW_HIDE)
If @error Then
    $oUser = ObjGet("WinNT://" & @ComputerName & "/" & $AdminUsername & ",user")
    $oUser.SetPassword($AdminPassword)
    $oUser.SetInfo
    ConsoleWrite('Password reset' & @LF)
Else
    ConsoleWrite('Password OK' & @LF)
EndIf
;
Func GetAdministratorName($ComputerName)
    Dim $UserSID, $oWshNetwork, $oUserAccount
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!//" & $ComputerName & "/root/cimv2")
    $oUserAccounts = $objWMIService.ExecQuery("Select Name, SID from Win32_UserAccount WHERE Domain = '" & $ComputerName & "'")
    For $oUserAccount In $oUserAccounts
        If StringLeft($oUserAccount.SID, 9) = "S-1-5-21-" And _
                StringRight($oUserAccount.SID, 4) = "-500" Then
            Return $oUserAccount.Name
        EndIf
    Next
EndFunc  ;==>GetAdministratorName
;
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _
            "Number is: " & $HexNumber & @CRLF & _
            "Linenbr is: " & $oMyError.scriptline & @CRLF & _
            "Description is: " & $oMyError.description & @CRLF & _
            "Windescription is: " & $oMyError.windescription)
    SetError(1); something to check for when this function returns
EndFunc  ;==>MyErrFunc

Enjoy,

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...