Payback Posted October 27, 2021 Share Posted October 27, 2021 I'm trying to rename an user account in Autoit. In normal situations, it would work with this code: #NoTrayIcon #RequireAdmin $UserName = @UserName $Password = 'idk' $strComputer = @ComputerName $NewUser = "someuser" ;Create UserID $colAccounts = ObjGet("WinNT://" & $strComputer & "") $objUser = $colAccounts.Create("user", $UserName) $objUser.SetPassword ($Password) $objUser.Put ("Fullname", $NewUser) $oComputer = ObjGet("WinNT://" & @ComputerName) $oNewUser = $oComputer.MoveHere($objUser.ADsPath, $NewUser) $objUser.SetInfo But when the user was renamed from the control panel, it changes the ADsPath correctly as you can see in the image I posted: But the user name in the logonui and the user account object in the image still stays at the old user name (usrname) for whatever reason. Could someone help me fix this problem? Link to comment Share on other sites More sharing options...
ad777 Posted December 3, 2021 Share Posted December 3, 2021 On 10/28/2021 at 1:33 AM, Payback said: I'm trying to rename an user account in Autoit. In normal situations, it would work with this code: #NoTrayIcon #RequireAdmin $UserName = @UserName $Password = 'idk' $strComputer = @ComputerName $NewUser = "someuser" ;Create UserID $colAccounts = ObjGet("WinNT://" & $strComputer & "") $objUser = $colAccounts.Create("user", $UserName) $objUser.SetPassword ($Password) $objUser.Put ("Fullname", $NewUser) $oComputer = ObjGet("WinNT://" & @ComputerName) $oNewUser = $oComputer.MoveHere($objUser.ADsPath, $NewUser) $objUser.SetInfo But when the user was renamed from the control panel, it changes the ADsPath correctly as you can see in the image I posted: But the user name in the logonui and the user account object in the image still stays at the old user name (usrname) for whatever reason. Could someone help me fix this problem? https://www.autoitscript.com/forum/topic/29055-rename-local-user-accounts/ iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
Payback Posted December 22, 2021 Author Share Posted December 22, 2021 thank you ad777 for the link but i figured out how to fix it myself Link to comment Share on other sites More sharing options...
spudw2k Posted December 22, 2021 Share Posted December 22, 2021 Did you use the method in the link posted by ad777, or another method? It may be helpful to future scripters with the same need to know how you solved it. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Payback Posted January 10, 2022 Author Share Posted January 10, 2022 Hello, spudw2k, i just used another method that involves changing a little bit my code (reconfigure the com objects in my code) and it worked. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now