Categories: User Accounts

Remove user from group using command line

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

net localgroup group_name user_name /delete

This removes the group membership. It does not delete the user account or the group. Put group names and user names containing spaces in double quotes.
For example to remove user John from administrators group we can run the below command.

net localgroup administrators John /delete

Before removing an administrator, make sure another account you can use still has administrator access.
In Windows 11 and Windows 10, even if you run the above command from an administrator login, you may still get an access denied error like the one 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 an elevated Command Prompt. 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.

We can check the remaining members with:

net localgroup administrators

Below are few more examples for net localgroup command.
Use net localgroup without arguments to see which groups exist on your computer. Built-in group names can differ with the Windows display language, and not every group below is present on every installation.

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?

First list the members of the group:

net localgroup "group_name"

We can remove more than one member by giving their names in the same command. For example:

net localgroup "group_name" "John" "Mary Smith" /delete

Replace the example names with the members you intend to remove, then list the group again to check the result.
Avoid feeding the unfiltered output of net localgroup into for /F for deletion. The output includes headings and status messages, and the default for /F parsing also splits names containing spaces.

Srini

View Comments

  • please how to create this command as patch file i tried to do this as .bat file and there is no action taken

  • These people sound like they are trying to hack people like my computer has been hacked. I put in your commands and many many more but keep getting the system error 5 response. I'm right in front of the computer. Someone is slowly but surely putting administration restrictions on all my programs to where I can't access any of them. They crashed my other computer now this one's almost dead also. What can I do to stop this,? I would appreciate any advice. Im at my ropes end here. Computer just now crashed with command net user administrator remove and it's been black since. I'm loosing my mind and that's saying a lot as I'm schitzophrenic already. Please give me some help so I can at least fight back.

  • i have a domain user account added to multiple servers; i have tried removing but get the error code 1, what could be the solution?
    Thank you,

  • I am trying to delete all users from a Administrator group in Single Command. So i tried this command : for /F %i in ('net localgroup group_name') do net localgroup group_name %i /delete

    When i run this, it is worked for all accounts "except" one user where the account name has space for example : "Suresh Gopalan" I know we have to give double quotes for this to work, but here i do not know where to give in the above command. Could any one help?

  • Can I delete the one particular user from N number of servers using above ?Is there any chance for that

    • You can use psexec tool to run net user commands on each of the servers. Curious to know - do you have this user as a local user on N servers? or is it a domain user account and was added to multiple servers?

  • Hi,
    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.

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

      net localgroup Administrators "TDBFG\Test Group" /delete
  • 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.

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

    psexec \\ c:\windows\system32\net localgroup administrators  /delete
  • Ricardo,

    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..

Recent Posts

Manage Print Jobs in Windows 11 & 10 Using PowerShell

Use PowerShell to list, pause, resume, and cancel print jobs in Windows 11 and Windows…

5 days ago

Add New User Account from Command Prompt (CMD)

Create local or domain user accounts from Command Prompt in Windows 11 and Windows 10…

4 years ago

Delete directory from command line [Rmdir]

Do you want to delete a directory from Windows Command Prompt (CMD)? This post explains…

4 years ago

TaskKill: Kill process from command line (CMD)

We can kill a process from GUI using Task manager. If you want to do…

4 years ago

Kill Chrome from command line

Chrome is definitely the stable browser compared to other ones and it has been my…

4 years ago

Find Windows OS version from command line

Windows has multiple command line utilities that can help find the version of the Windows…

4 years ago