Removing Unwanted User Profiles with Delprof

User profiles contain a considerable amount of information. In a shared workstation environment, where multiple users log on to a single computer, the amount of disk space used by profile data may become quite large. For an easy and straightforward way to keep the profile data tidy, Delprof is a great start.

There are several scenarios where removing aged profiles can be beneficial:

  • An environment that is shared among task-based employees
  • An open workstation in a corporate area for leisure use (such as a lunch or break room)
  • Workstations utilized by temporary or seasonal employees

Using the User Profile Deletion Utility (Delprof)

The command, as of version 5.2, has a number of arguments that can be used:

usage:  DELPROF [/Q] [/I] [/P] [/R] [/C:\<computername>] [/D:<days>]

/Q      Quiet, no confirmation.

/I      Ignore errors and continue deleting.

/P      Prompts for confirmation before deleting each profile.

/R      Delete roaming profile cache only

/C      Remote computer name.

/D      Number of days of inactivity.

The command usage is very simple by design. For an unattended, automated cleaning, focus on the switches Q (Quiet), I (Ignore Errors), and D (Number of Days).

Scenario: You need to purge any profile that has not been used in 30 days each time a user logs on the computer.

Building a Delprof Command

The first step is to build the command. To accomplish the scenario, use:

delprof.exe /q /i /d:30

This will quietly remove any profile that has not been loaded in the last 30 days, skipping instances where errors are encountered.

Automatically Running the Delprof Command at User Logon

The next step requires a bit more thought because simply linking to the user logon script will not work. A normal user will not have the authority to purge other employee’s user profiles. The best solution is to use a Group Policy Preference (GPP) that generates a computer scheduled task to run at user logon.

Step 1: Create the GPP

Create a new GPP with a computer scheduled task.

Step 2: Enter the Name and Path

For the name, use “Delete Old Profiles” or anything that clearly demonstrates the purpose for other Administrtors when viewing the task scheduler. Provide the path to the delprof.exe file; either put it on a server share, or use a method to push it to the workstations (GPP, robocopy, etc.)

Add the 3 arguments outlined in the command section: /q /i /d:30

Step 3: Set the Schedule

In the Schedule tab, set the Scheduled Task to run “At logon”. Ignore the start time – occasionally it will become adjustable but the value is irrelevant.

Step 4: Remove when not Applied

A good practice is to check the “Remove this item when it is no longer applied” flag located in the Common tab of the scheduled task, forcing the GPP to remove the scheduled task if the workstation is moved to an Organizational Unit (OU) where this policy is not applied.

Note: Using this option will force the scheduled task into “Replace” mode deleting any existing scheduled task with this name and replacing it with the one in the policy.

This simple and free tool, provided by Microsoft, is a great way to keep the user profiles area free of aged, unwanted data. The process is also very fast, deleting dozens of old profiles in less than 10 seconds.