Batch to delete multiple users

Asked

Viewed 84 times

2

Good afternoon, So, I have to do a weekly wipe on a machine that is connected to a domain, and delete all of its (network) users.

My plan of action was to create a Batch that delete all user folders from C: Users start with "2000", and then enter the regedit and erased users' residual files on Computer HKEY_LOCAL_MACHINE SOFTWARE Microsoft Windows NT Currentversion Profilelist so that you have no problems if the user that was deleted Log again.

The reason why I want to delete only folders starting with 2000, is that this way I would not delete my user folder (which in case starts with 1040). goes straight from the folder to get a better sense.

 Pasta de C:\Users

13/11/2019  14:58    <DIR>          .
13/11/2019  14:58    <DIR>          ..
03/12/2019  11:54    <DIR>          10202089
09/01/2020  14:44    <DIR>          10401794
25/10/2019  15:13    <DIR>          20005500
13/11/2019  15:59    <DIR>          20006093
25/10/2019  15:13    <DIR>          20006253
25/10/2019  15:13    <DIR>          20006421

I’m having trouble making this conditional in the Batch script, I can’t find a way to delete only these folders in specific (the ones starting with "2000"), someone could help me create a parole for this case?

(if you have any other method that I can apply please tell me)

  • Your question seems to have some problems and your experience here in Stack Overflow may not be the best because of this. We want you to do well here and get what you want, but for that we need you to do your part. Here are some guidelines that will help you: Stack Overflow Survival Guide in English (short version). If the help is very simple it is still possible to do in the comments.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.