programaticly managing local users/groups

Red Squirrel

No Lifer
May 24, 2003
70,592
13,807
126
www.anyf.ca
Anyone know any good ways to programaticly delete users/groups in windows 2k/xp? I'm guessing the SAM DB is part file part registry, and cannot be altered while windows is running, so wondering if there are built in ways in windows to access it, like commands or something.
 

hans007

Lifer
Feb 1, 2000
20,212
18
81
i know theres plenty of API for finding out user security tokens and such. i am not sure i fyou can say create a new user, but i would figure there probably is a way if you had local system priviledge. i'd google this or check msdn if i were you.
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
I have used VBscript to do this in the past. It is as easy as:

Deleting a User from a Local Group

Removes kenmyer from the local Administrators group on a computer named MyComputer.

strComputer = "MyComputer"
Set objGroup = GetObject("WinNT://" & strComputer & "/Adminstrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer,user")

objGroup.Remove(objUser.ADsPath)

More sample scripts at this website: http://www.activexperts.com/ac...ersgroups/localgroups/
 

Red Squirrel

No Lifer
May 24, 2003
70,592
13,807
126
www.anyf.ca
Found some stuff thats very useful. Functions NetUserDel, NetUserEnum etc... Have to include a library but it came with devcpp so got lucky there.
 

TruePaige

Diamond Member
Oct 22, 2006
9,874
2
0
Originally posted by: KB
I have used VBscript to do this in the past. It is as easy as:

Deleting a User from a Local Group

Removes kenmyer from the local Administrators group on a computer named MyComputer.

strComputer = "MyComputer"
Set objGroup = GetObject("WinNT://" & strComputer & "/Adminstrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer,user")

objGroup.Remove(objUser.ADsPath)

More sample scripts at this website: http://www.activexperts.com/ac...ersgroups/localgroups/

I find that rather useful. Thanks!