![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Editing Full Name of a local user Hi guys! I need to rename an administrator local user and reset the full name of this. For rename, I use this script: -----------SCRIPT START-------------------- ' code start sOldUser = "OldAdmin" sNewUser = "NewAdmin" sComputerName = "PC0001" Set colUsers = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & sComputerName & "\root\cimv2").ExecQuery _ ("select Name from Win32_UserAccount where name = '" & sOldUser & "'") 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 -----------SCRIPT END-------------------- But how I can do to reset the full name of user "NewAdmin" ?? How I can modify my script? Thanks, Valerio |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Editing Full Name of a local user <valerioweb@xxxxxx> wrote in message news:97355677-1626-424b-bb3f-8d3805e7dd71@xxxxxx Quote: > Hi guys! > I need to rename an administrator local user and reset the full name > of this. > > For rename, I use this script: > > -----------SCRIPT START-------------------- > > ' code start > > sOldUser = "OldAdmin" > sNewUser = "NewAdmin" > > sComputerName = "PC0001" > > Set colUsers = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" _ > & sComputerName & "\root\cimv2").ExecQuery _ > ("select Name from Win32_UserAccount where name = '" & sOldUser & > "'") > > 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 > > -----------SCRIPT END-------------------- > > But how I can do to reset the full name of user "NewAdmin" ?? > How I can modify my script? > > Thanks, > Valerio is exposed by the Win32_UserAccount class. Also, the following link suggests a slightly different query. http://www.microsoft.com/technet/scr...6/hey0517.mspx I would suggest:============strComputer = "MyComputer" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ & strComputer & "\root\cimv2") Set colAccounts = objWMIService.ExecQuery _ ("Select * From Win32_UserAccount Where LocalAccount = True And Name = '" & sOldUser & "'") For Each objAccount in colAccounts objAccount.FullName = "NewAdmin" objAccount.Rename sNewUser Next==========I don't find documentation for a SetInfo method, so apparently that is not required by the Win32_UserAccount class of WMI. -- Richard MuellerMVP Directory ServicesHilltop Lab - http://www.rlmueller.net-- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| The disappearance of local disk (D:) after full system recovery in Vista Home Premium | Vista file management | |||
| renaming Local user account and Changing "Full Name" of same Local | VB Script | |||
| Full Local Access for Domain Admins | Network & Sharing | |||
| local user | PowerShell | |||
| local user please | PowerShell | |||