Change Administrator Name

T

Tony

I am trying to write a batch file to run after my
unattended install is finished. I want it to change my
adminstrator account name. I have the password being set
during the unattended installation but I want the
Administrator name changed. I have tried to work with the
net command to accomplish this and I am at a dead end. Any
help would be appreciated.

Tony
 
T

Torgeir Bakken (MVP)

Tony said:
I am trying to write a batch file to run after my
unattended install is finished. I want it to change my
adminstrator account name. I have the password being set
during the unattended installation but I want the
Administrator name changed. I have tried to work with the
net command to accomplish this and I am at a dead end. Any
help would be appreciated.

Hi

Several ways to do this, the link below will give you a "pure" vbscript
solution, as well as two command line utilities (BuiltIn.exe and Cusrmgr.exe)

http://groups.google.com/[email protected]
 
D

David Wang [Msft]

I do the exact same thing after my unattend installs and custom batch file,
except my unattend installs use a common administrator name/password, so I
always change both the name and password.


The following lines of Script code, which work from Windows 2000 and up,
changes the username. You can use %USERNAME% and %USERDOMAIN% to capture
the current logged in user.

var Domain = "computername";
var User = "Administrator"
var NewValue = "NewAdministratorName";

var objRoot = GetObject( "winmgmts://./root/cimv2" );
var objUser = objRoot.Get( "Win32_UserAccount.Domain='" + Domain +
"',Name='" + User + "'" );
var ReturnCode = objUser.Rename( NewValue );


The following changes the password:
var NewValue = "NewPassword";
objUser = GetObject( "WinNT://" + Domain + "/" + User + ",User" );
objUser.SetPassword( NewValue );


--
//David
IIS
This posting is provided "AS IS" with no warranties, and confers no rights.
//
I am trying to write a batch file to run after my
unattended install is finished. I want it to change my
adminstrator account name. I have the password being set
during the unattended installation but I want the
Administrator name changed. I have tried to work with the
net command to accomplish this and I am at a dead end. Any
help would be appreciated.

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top