Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way through command line to remvoe all the users in a security group (from Local Users and Groups)?

I can remove a single user with "net localgroup", but I don't know who is in the group.

share|improve this question
    
Why don't you just remove the entire group? – Ramhound Oct 11 '12 at 17:04
    
I want to remove all the users that were entered in this groups every week. The group is still needed. Could I remove and re-create the group? – the_lotus Oct 11 '12 at 18:41
up vote 1 down vote accepted

A script would be a better solution but here is the command. (Don't forget to change groupname)

for /F "skip=6" %i in ('net localgroup groupname') do net localgroup groupname %i /delete

If you take a look at 'net localgroup groupname' structure you will see why I skip 6 tokens and that it produces an error at the end, because the last token is the confirmation that the command was successfully executed. As far as I know you need to write a script to get rid of that.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .