Delete Multiple Windows Accounts by using CMD

5,861

Solved by TwistyImpersonator

No, it is not possible to delete multiple accounts or all windows accounts. You have to log into each account deleting them 1 by 1 using the command:

Net User "%username%" /DEL
Share:
5,861
Bita
Author by

Bita

Updated on September 18, 2022

Comments

  • Bita
    Bita over 1 year

    Is there a way to achive so? I usually test on my computer different CMD commands with different privileges, so I create many users (I know that I can change the privileges by using net user but I prefer to do so this way). I was thinking about a variable like %allusers% or something like that to delete all users and create a new only one, like this:

    net user %allusers% /del & net user "USERNAME" /add
    

    or

    net localgroup users %allusers% /del
    

    Basically I want to delete or change privileges from window's users by a variable like %allusers%.

    • Ramhound
      Ramhound over 6 years
      There isn’t a way to delete multiple user profiles, to delete all users in a user group, you have to loop through each user in the group and delete it. How you want to do what you want isn’t possible.
    • DavidPostill
      DavidPostill over 6 years
      Think about it for moment. If you could delete all users you would remove the currently running user, which is a bad thing :)
    • Bita
      Bita over 6 years
      @davidpostill ... For that i'm saying to create a new user after deleting all ...
    • DavidPostill
      DavidPostill over 6 years
      @Bita You are missing the point. There must be at least one user (with the appropriate privileges) to create another user. You can never have zero users.
    • Bita
      Bita over 6 years
      @davidpostill Yes you can. You can have just one admin user, delete it, and create another, but if you delete the unique admin user it cannot be completely deleted if you do not create other admin account. Knowing that, I want to delete all windows users, and in the same session create other admin user.
    • I say Reinstate Monica
      I say Reinstate Monica over 6 years
      No, you can't delete all of a machine's accounts. For example, attempting to delete the built-in Administrator account will give you the error "Cannot perform this operation on built-in accounts."
    • Bita
      Bita over 6 years
      @TwistyImpersonator But is it possible to delete other account, not in which I am logged in, by using a variable? For example: net user %user2% /del
    • I say Reinstate Monica
      I say Reinstate Monica over 6 years
      @Bita unfortunately no. That command only works on one account at a time.