Delete Multiple Windows Accounts by using CMD

0

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

Bita

Posted 2018-01-01T16:51:44.267

Reputation: 333

1There 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. – Ramhound – 2018-01-01T16:57:55.073

1Think about it for moment. If you could delete all users you would remove the currently running user, which is a bad thing :) – DavidPostill – 2018-01-01T17:30:19.210

@davidpostill ... For that i'm saying to create a new user after deleting all ... – Bita – 2018-01-01T18:01:54.070

1@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. – DavidPostill – 2018-01-01T18:03:28.583

@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. – Bita – 2018-01-01T19:00:19.147

3No, 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." – I say Reinstate Monica – 2018-01-01T19:40:25.887

@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 – Bita – 2018-01-02T14:20:32.857

@Bita unfortunately no. That command only works on one account at a time. – I say Reinstate Monica – 2018-01-02T14:22:25.373

Answers

1

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

Bita

Posted 2018-01-01T16:51:44.267

Reputation: 333