Script to replace Delprof.exe

by Jeremy Saunders on July 30, 2008

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!

Jeremy Saunders

Jeremy Saunders

Technical Architect | DevOps Evangelist | Software Developer | Microsoft, NVIDIA, Citrix and Desktop Virtualisation (VDI) Specialist/Expert | Rapper | Improvisor | Comedian | Property Investor | Kayaking enthusiast at J House Consulting
Jeremy Saunders is the Problem Terminator. He is a highly respected IT Professional with over 35 years’ experience in the industry. Using his exceptional design and problem solving skills with precise methodologies applied at both technical and business levels he is always focused on achieving the best business outcomes. He worked as an independent consultant until September 2017, when he took up a full time role at BHP, one of the largest and most innovative global mining companies. With a diverse skill set, high ethical standards, and attention to detail, coupled with a friendly nature and great sense of humour, Jeremy aligns to industry and vendor best practices, which puts him amongst the leaders of his field. He is intensely passionate about solving technology problems for his organisation, their customers and the tech community, to improve the user experience, reliability and operational support. Views and IP shared on this site belong to Jeremy.
Jeremy Saunders
Jeremy Saunders

Previous post:

Next post: