Delete Windows local account

Need to an action script to delete any local account which will remove the user depending upon Start name of the user.

For examples:
We have one user whose name of it starts with “local_ritx_*” and ends with computer name.

Hi
First generate relevance to list the local users that start with your specific string:-

q: names of local users whose (name of it as lowercase starts with “local_ritx”)
A: local_ritx_AAA
A: local_ritx_BBBB

Now we can write an action script that creates cmd file to use the net user /delete command to delete each of the found users. Something like this:

delete __appendfile
appendfile {concatenation “%0d%0a” of (“net user %22” & it & “%22 /delete”) of names of local users whose (name of it as lowercase starts with “local_ritx”)}
delete DelUsers.cmd
move __appendfile DelUsers.cmd
waithidden DelUsers.cmd

This creates a cmd file like this:

net user “local_ritx_AAA” /delete
net user “local_ritx_BBBB” /delete

and runs it.
As this is destructive, I strongly suggest you test this first by deleting the wiathidden line and looking at the cmd file!

1 Like