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.

@echo off
Set loglocation=%SystemDrive%\buildlogs
if not exist %loglocation% md %loglocation%
cscript “%SystemRoot%\DeleteProfiles.vbs” /L “%loglocation%\DeleteProfiles.txt” /V
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.

@Echo Off
SCHTASKS /Create /TN “Delete inactive profiles” /RU “NT AUTHORITY\SYSTEM” /ST 02:30 /SC Daily /F /TR “%SystemRoot%\DeleteProfiles.cmd”

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

Independent Consultant | Contractor | Microsoft & Citrix Specialist | Desktop Virtualization Specialist at J House Consulting
Jeremy is a highly respected, IT Professional, with over 30 years’ experience in the industry. He is an independent IT consultant providing expertise to enterprise, corporate, higher education and government clients. His skill set, high ethical standards, integrity, morals and attention to detail, coupled with his friendly nature and exceptional design and problem solving skills, makes him one of the most highly respected and sought after Microsoft and Citrix technical resources in Australia. His alignment with industry and vendor best practices puts him amongst the leaders of his field.
Jeremy Saunders
Jeremy Saunders
Jeremy Saunders
  • Thanks for the kind words and credit 🙂

  • Erik Oxaal

    Hi, DeleteProfiles.vbs doesn’t work on Win 7 or Server 2008, but I have an updated version available: the download link is at


    • jeremy

      Thanks Erik.

      I’ve actually had mixed results with the script too and have certainly found that it’s not doing its job on Win 2008 R2, but haven’t really had the time to look into it. Like you say, and with respect to Joe, it does have some flaws. You’ve done a great job with the re-write. Thank you for sharing and leaving a comment so that readers can link across to your post.


      • Erik

        You’re welcome, and as you said, all respect to Joe: starting with an existing script saves one from re-inventing the wheel.

        By the way, a “heads up”: the syntax for the script’s parameters has changed in my incarnation and there are also some behavioral changes such as read-only being the default and “include” and “exclude” not being mutually exclusive, so any batch files to run the script would have to be updated.

  • Pingback: Clean Citrix Profile « Roshan Ratnayake – Solutions Architect()

Previous post:

Next post: