Search the Community
Showing results for tags 'local administrator'.
-
We changed security procedures and are changing the name of the local admin account on a computer. I created a script that changes the account, but only if the account is named "administrator". I need to change it to work with any administrator account name. Here is what I tried: #RequireAdmin #include<LocalAccount.au3> Global $OKMSGBOX = 1 $strComputer = "." ;This and the following two lines are newly added $CPU = ObjGet("WinNT://" & $strComputer & ",Computer") Local $sAdminAcct = $CPU.GetObject("User", "Administrator") Local $sUsername = InputBox('Password', 'New Admin Username: ', '', '*', -1, -1, 0, 0, 10000) MsgBox($OKMSGBOX, '', $sAdminAcct) ;for testing. Diplays a blank msgbox $boolrun = 1 While ($boolrun) $sPassword1 = InputBox('Password', 'New Admin Password: ', '', '*', -1, -1, 0, 0, 10000) $sPassword2 = InputBox('Password', 'Re-Enter New Admin Password: ', '', '*', -1, -1, 0, 0, 10000) If $sPassword1 == $sPassword2 Then _AccountSetPassword($sAdminAcct, $sPassword1, '0') _AccountRename($sAdminAcct, $sUsername, @ComputerName) $boolrun = 0 Else MsgBox($OKMSGBOX, '', 'The passwords you entered do not match.' & @CRLF _ & 'Please re-enter the desired admin credentials.') EndIf WEnd I added a few lines to assign the local admin account to the variable "$sAdminAcct" and then added the variable to the "_Account..." functions in place of "administrator". However, like it says above, the variable is blank. I enter all the credentials required, but it won't change the name. Any ideas how to get it to work?