Home > Software design >  Code to automatically remove users that have numbers from 1-500 at the end
Code to automatically remove users that have numbers from 1-500 at the end

Time:07-08

I recently ran a program that automatically generates 500 users on a virtual machine, and it is making it lag on the lockscreen. Basically, it generates 500 users in the format of: "userX (user1, user2, user3 etc.). I was wondering if there could be a batch script / powershell script / just anything that could be done to remove all of these users. The process can be done manually using net user userX /del but it could probably be automated using the same command again but with numbers counting up. Thanks.

CodePudding user response:

for /L %a in (1,1,500) do @net user user%a /del

Or if in a batch file:

for /L %%a in (1,1,500) do @net user user%%a /del
  • Related