≡ Menu

Remove user from group using command line

We can delete users from a group using command line too. We can use below net localgroup command for this.

net localgroup grpup_name user_name /delete

For example to remove user John from administrators group we can run the below command.

net localgroup administrators John /delete

This command works on all editions of Windows OS i.e Windows 2000, Windows XP, Windows Server 2000, Windows Vista and Windows 7. In Vista and Windows 7, even if you run the above command from administrator login you may still get access denied error like below.

C:\> net localgroup administrators techblogger /delete
System error 5 has occurred.
Access is denied.

The solution for this is to run the command from elevated administrator account. See how to open elevated administrator command prompt

When you run the above command from elevated command prompt:

C:\>net localgroup administrators techblogger /delete

The command completed successfully.

Below are few more examples for net localgroup command.

To delete a user from Remote desktop users group:

net localgroup "Remote desktop users" username /delete

To remove a user from Power users group:

net localgroup "Power users" username /delete

To remove a user from Debugger users group:

net localgroup "Debugger users" username /delete

How to remove all users from a group?

There is no single direct command to delete all users from a group. You can use net localgroup in combination with for command to do this. I am giving a script below which seems to be working.

for /F %i in ('net localgroup group_name') do net localgroup group_name %i /delete

Just replace the group_name with your group name. Note that this runs a series of /delete operations and in the first few cases it returns errors. (If you understand the above command, you will be knowing the reason for this.)

There could be a better solution to do this..but this is the one I know of..

Related Posts:
Get list of user groups
Create a user group

{ 7 comments… add one }
  • Anonymous September 6, 2010, 4:53 am

    How to remove all users from a group using a single command?

  • Ricardo November 4, 2010, 12:39 am

    Having a bit of a problem here. I used the Offline NT registry editor at http://pogostick.net/~pnh/ntpasswd/ to elevate a normal user account to admin, and now I cannot change it from admin to normal user.
    I inputted the following cmds in command line:
    net localgroup administrators CompAdmin /delete
    And I got sys error 1377 that says CompAdmin is not a member of the group. Then I input net localgroup administrators CompAdmin /add and it says the account is already a member of the group..what can I do? I cannot reinstall my OS or recreate another account..

  • Techblogger November 4, 2010, 4:47 am


    May be the registry hack is not a complete solution to elevate a user to administrator.. It's always better to be cautious about registry hacks..Though most of the operations involve single registry changes some operations require changing multiple keys in the registry..

    Have you tried it from GUI? I mean using nusrmgr.cpl or compmgmt.msc

    One solution I would suggest is to undo the registry change the tool has done..This can work only if you have the details of what the tool has done..

    Other suggestion is to delete that user and add a new user account afresh.. take back up of all the user data..

  • Erik August 1, 2013, 8:38 pm

    Thanks, I used PSExec to run this against remote computer and saved HOURS of work.

    psexec \\ c:\windows\system32\net localgroup administrators  /delete
  • Pavan April 28, 2015, 4:13 am

    How to delete the logged in user from a group? I can’t specify a specific user name in the command, I just want to use the logged in user name.

  • tk November 17, 2015, 8:44 pm

    was hoping you help me out. Im trying to delete a security group from the local administrators group. using the following syntax
    net localgroup Administrators TDBFG\Test Group /delete

    but I get the messaged that “there is no such global user or group : test” and “there is no such global user or group “group”.

    I think its because of the space. can you please advise? thanks.

    • admin November 18, 2015, 6:09 am

      Yes, it’s because of the space. You should enclose the group name into double quotes.

      net localgroup Administrators "TDBFG\Test Group" /delete

Leave a Comment