|
renaming Local user account and Changing "Full Name" of same Local I have the following code snipet that does a good job of renaming a local
user account on a computer.
sOldUser = "Agency_user"
sNewUser = "12LEPATTEST"
strComputer = "."
Set colUsers = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2").ExecQuery _
("select Name from Win32_UserAccount where name = '" & sOldUser & _
"'")
For Each objAccount in colAccounts objAccount.FullName = "NewAdmin"
objAccount.Rename sNewUser
If colUsers.Count > 0 Then
For Each oUser In colUsers
iRC = oUser.Rename(sNewUser)
If iRC = 0 Then
WScript.Echo "User renamed"
Else
WScript.Echo "Rename method returned ERROR # " & iRC
End If
Next
Else
WScript.Echo "No user found"
End If
I also need to change the "Full Name" of the same account. I have not been
able to find how to do that. Can some one help me/ |