Joe Shonk has written a very nice Delete Profiles Script to replace the lack of flexibility found in the DELPROF.exe tool. I’ve used it for my latest XenApp rollout, and have found that it works really well 🙂 See below for further information as to how I have implemented it.
Warren Simondson of Ctrl-Alt-Del IT Consultancy has released a command-line utility called REMProf to delete local user profiles that are not in use when this command is executed. Andy Morgan has created a great blog to demonstrate how usefull this tool can be to remove a user profile from multiple Terminal / Citrix servers.
Deleteprofiles.cmd “wrapper” and Scheduled Task creation script.
Place the  deleteprofiles.cmd and deleteprofile.vbs scripts in the %SystemRoot% (Windows) folder.
———————Deleteprofiles.cmd————————–
@echo off
SetLocal
Set loglocation=%SystemDrive%\buildlogs
if not exist %loglocation% md %loglocation%
cscript “%SystemRoot%\DeleteProfiles.vbs” /L “%loglocation%\DeleteProfiles.txt” /V
EndLocal
EXIT /b 0
—————————————————————–
However, and we need to go one step deeper here. I create it as a scheduled task that runs at 2:30am every day. One of the bigest advantages of using a script like this is that is can be run as the Local System account, where as Delprof has its issues as documented in Microsoft Technet article KB262223.
———————–SceduledTasks.cmd———————-
@Echo Off
SCHTASKS /Create /TN “Delete inactive profiles” /RU “NT AUTHORITY\SYSTEM” /ST 02:30 /SC Daily /F /TR “%SystemRoot%\DeleteProfiles.cmd”
EXIT /B
—————————————————————-
This method is 100% successful and creates a very good log file that can be reviewed as needed.
Thanks again Joe!