Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Local user account to have admin rights.

Status
Not open for further replies.

guyvernews

IS-IT--Management
Jan 3, 2002
48
GB
Dear all,

Is there a way to script to add a local user account to become a member of the administrators group?

Thanks

Paul
 
You can use ADSI.

If the current logged-on user doesnt have the necessary permissions, use the following replacing MyComputer with the name of the PC, Admin with a username who does have the necessary permissions, pass with the username's password.

Set oWinNT = GetObject("WinNT:")
Set oComputer = oWinNT.OpenDSObject("WinNT:MyComputerName,Computer","admin","pass",1)

If the current logged-on user does have the necessary permissions, use the following replacing MyComputer with the name of the PC.

Set oComputer = GetObject("WinNT://MyComputer,Computer")

Then, get the group and add the user:

Set oGroup = oComputer.GetObject("Group","Administrators")
If Not oGroup.IsMember("WinNT://yourdomain,youruser") Then
oGroup.Add "WinNT://yourdomain,youruser"
End If Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top