This is more of a one off utility to use when things go wrong but using GPO to delete profiles over a certain age is much tidier. I needed to clear all profiles (even the ones that were used on the same day). The story why it got to this point is quite long but lets just say that if you’re moving redirected folders to a different server definitely make changes to your GPO first.
Some useful articles on this:
So if for any reason you’d like to delete local user profiles from a bunch of PCs you will definitely find the Delprof utility useful. For Windows XP and lower you can download to file from Microsoft. You will however notice that this is no good for Windows 7, that’s where Helge Klein’s Delprof2 comes in handy. The software is free to use for non-profit and educational organisations which nicely covered my client. The commercial license costs around £260 which isn’t that small amount but if you’re going to get some use out of it it’s not ridiculous either.
I had nearly 900 PCs to contend with and wanted to run delprof2 against a list of PC names. For this purpose I’ve written a fairly simple batch file, which no doubt could be much improved but it did the job quite nicely.
del /q log.txt 2>nul
del /q errorlog.txt 2>nul
for /f %%i in (pclist.txt) do call :proc %%i
echo processing %1 …
ping -n 2 %1 >nul 2>nul
if %ERRORLEVEL% gtr 0 (
echo %1 -offline >>errorlog.txt
echo deleting on %1
echo deleting on %1>>log.txt
DelProf2.exe -c:%1 -i -q
echo %1 Complete
echo %1 Complete>>log.txt
This script assumes there’s a PClist.txt file containing a list of computer names (IP addresses would work too) and delprof2.exe in the same directory as the batch file itself.