Like today I do not have really a lot of time to help them (too much projects to finish and manage today) I decided to do a 5 min batch script.
Here it is DeleteLocalUsers.cmd
set inputfile=users.txt
set result=result.txt
echo. >%result%
for /F %%i IN (%inputfile%) Do echo %%i >> %result% 2>>&1 & net user %%i /delete >> %result% 2>>&1
This batch use an input file named users.txt that containing users to delete like this:
aaaaaaa
bbbbbbb
No you just to run batch script to delete users (report file named result.txt)
Here user aaaaaa whas created before and bbbbbb does not exist
aaaaaa
The command completed successfully.
bbbbbb
The user name could not be found.
More help is available by typing NET HELPMSG 2221.
For better report, you can improve batch by testing if it's a successfull deletion by testing "successfully" with findstr command and errorlevel
If you need to execute this batch remotely on multiple computers, use psexec in for loop with a computers.txt file
(for example see in my blog in HP Onboard administrator and Citrix backup posts)
To download it
No comments:
Post a Comment