Sign in to follow this  
Followers 0
MrTiz

Change the name of windows' s account

8 posts in this topic

Hi, It' s possible change immediately the name of windows's account using cmd or registry key or any other metods?

VERY IMPORTANT: The reboot mustn't be necessary for apply the changes.

P.S. I wouldn't change the computer' s name.

Sorry for my bad english, but I'm italian and I don't speak english very well.

Share this post


Link to post
Share on other sites



up...

Share this post


Link to post
Share on other sites

yes, the account using for start pc, I would change the name of account

Share this post


Link to post
Share on other sites

Here you have something to play with:

Init objects
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler 
$UserName = 'Fred'
$Password = 'Wilma123'
$strComputer = @ComputerName
;***********************
;Create UserID
$colAccounts = ObjGet("WinNT://" & $strComputer & "")
$objUser = $colAccounts.Create("user", $UserName)
$objUser.SetPassword ($Password)
$objUser.Put ("Fullname", "Test User")
$objUser.Put ("Description", "Test User description")
$objUser.Put ("PasswordExpired", 1)  ;expire the password
$objUser.SetInfo
;***********************
;Add User to group 
$objGroup = ObjGet("WinNT://" & $strComputer & "/Administrators,group")
$objGroup.Add($objUser.ADsPath)
;***********************
; Rename User
$colAccounts = ObjGet("WinNT://" & $strComputer & "")
$objUser = $colAccounts.Create("user", $UserName)
$OldUser = "Fred"
$NewUser = "Fredrenamed"
$oUser = ObjGet("WinNT://" & @ComputerName & "/" & $OldUser & ",user")
$oComputer = ObjGet("WinNT://" & @ComputerName)
$oNewUser = $oComputer.MoveHere($oUser.ADsPath, $NewUser)
; Delete User
$colAccounts = ObjGet("WinNT://" & $strComputer & "")
$objUser = $colAccounts.Delete("user", $NewUser)


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

You can pull the startup username from the registry.'

So, What is you goal here? Why rename the userid?

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I would rename the account' s name that is existing, and the function "Rename User" doesn't work.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I would rename the account' s name that is existing, and the function "Rename User" doesn't work.

Not sure what you expect but you could imagine that a post like this worthless.

oh..and the rename function works fine when applied properly.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sorry, the function work, You are the best, thank you very much

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