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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to modify a user in WinXP 1

Status
Not open for further replies.

Jouster

Programmer
Dec 4, 2000
82
US
I'm wondering if anyone knows how to modify a WinXP user.
I would like a program that can change the user from an administrator to a limited user.

I have found API's that will let you add or delete users, but not modify. Any help would be appreciated.

 
Jouster-

You will want to look at removing the user from the administrators group and then add the user to the standard users group.

Code:
Dim objComp
Dim objGroupAdmin
Dim objGroupUsers
Dim objUser
Dim strComp

strComp = "WinNT://corpdev3,Computer"

Set objComp = GetObject(strComp)
Set objUser = objComp.GetObject("user","test01")

Set objGroupAdmin = objComp.GetObject("group", "Administrators")
Set objGroupUsers = objComp.GetObject("group", "Users")

On Error Resume Next
'Ignore errors because it will error if the user is not in the admin group and will error if the user is already in the users group.
objGroupAdmin.Remove objUser.AdsPath
objgroupUsers.Add objUser.AdsPath

If you want the user to be a 'Power User', then add them to the 'Power Users' group...
 
Thanks bjd4jc. Although I'm getting a syntax error on the line

Set objComp = GetObject(strComp)

Havn't been able to fiure out why yet.


 
Figured it out.

i set strcomp to "Winnt://myComputername" and it worked fine.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top