Delprof Selective Profile Delete

Good evening,

Is it possible to selectively deny profile deletion through Delprof at command prompt without prompting e.g. the local administrator account? I want to automate profile deletion for profiles not used within 180 days but do not want several local profiles to be deleted. The only other alternative I have is to write a VBScript but why if delprof is available?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this out...
(you don't have to use delprof)

@echo off&&cls
echo Cleaning profiles ...
for /f "tokens=*" %%a in ('dir "%AllUsersProfile%\.." /b') do (
if not "%%a"=="<AnotherAccountYouWantToKeep>" ( if not "%%a"=="Administrator" ( if not "%%a"=="All Users" rd /q /s "%AllUsersProfile%\..\%%a" 2>NUL )
echo Done.
echo New profiles list :
dir "%AllUsersProfile%\.." /b
Barnardos_2LSAuthor Commented:
and235100: How does this differentiate profiles not used within 180 days?
It doesn't. Sorry - misread the question.
If you want this specification - you will need to use delprof.

You could create a script that automatically logs in as the local administrator every now and again - so the folder is modified, and therefore not deleted by delprof.

FYI: (syntax)


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Apologies that wasn't ideal - but thank you in any case.
Feroz AhmedSenior Network EngineerCommented:
Hi ,
You can Inactive that account by specifying this command delprof /D (Here "D" specifies Number of days of Inactivity for that particular account ).
We setup the domain administrator account and service accounts not to have server based roaming profiles. We set all users to have roaming profiles. We run delprof with the /r option limiting it to only the roaming profiles, thus not touching admin or service accounts. We do not use roaming profiles for administrator for several reasons, the key being Group Policey pushes all info needed for admin profile to work and when using the admin account seeing profile settigns form teh local box is often helpful introubleshooting.


Free Command-line Utility to Delete Local User Profiles - REMPROF

REMPROF is a command-line utility to delete local user profiles that are NOT

in use when this command is executed

The awesome Warren Simondson of Ctrl-Alt-Del IT Consultancy, has released

another killer FREE Microsoft Terminal Services / Citrix utility.  REMPROF

was written to replace the command DELPROF.EXE currently found in the MS

Windows Resource Kit. This utility offers extra features that will be of

benefit to all admins. REMPROF has the ability to delete user profiles on

the local machine based on age, username, or SID association. If a username

has been deleted from a Domain or Workgroup,  the profile often still exists

with only a SID assigned to identify it.  REMPROF can delete these profiles

completely from the file system and registry regardless of the profile age,

and without removing existing profiles of the same age.


This tool could be simply run from the command line at any time, or added as

a SCHEDULED TASK for regular cleaning of user profiles, reducing the overall

disk space used for locally based profiles.  


REMPROF will only function when executed by a user with ADMIN rights to the

profile directory.



REMPROF [/LIST|username|/A|/D:days|/AD:days] [/?]


 /LIST    - List all user profiles currently not in use (Default).

  username - Delete user profile based on username.


/A       - Delete all user profiles that have no username association

             i.e. The username has been deleted in Active Directory but

             a profile still exists in form of a SID.


/D:days  - Delete all user profiles equal to or older than the number of

             days specified. NB: /D: without a number is equal to /D:0.

             /D:0 will remove CURRENT user profiles not in use.


/AD:days - Delete all user profiles that have no username association

             and are equal to or older than the number of days specified.

             NB: /AD: without a number is equal to /AD:0.


 /?       - show this help file



REMPROF without parameters will execute the /LIST switch by default.


This application has been tested on the following platforms:

·          Windows 2003 Server SP1

·          Windows 2003 Server SP1 w/ Citrix PS 4.0

·          Windows 2003  Server SP1 (Terminal Server Application Mode)

·          Windows 2000  Server SP4

·          Windows 2000  Server SP4 w/ Citrix MF XP

·          Windows 2000  Server SP4 (Terminal Server Application Mode)

·          Windows 2000  Server SP4 w/ Citrix MF 1.8

·          Windows XP Professional (domain member)


This utility is FREEWARE and was written by Warren Simondson of Ctrl-Alt-Del

IT Consultancy, Australia.


Although written for Terminal Server and Citrix environments, this

application will function on non-TS/Citrix workstations and servers.



Click to download the Free Command-line Utility to Delete Local User

Profiles - REMPROF
URL to download REMProof Util

or Kindly download Remprof.doc and rename it to remprof.exe
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.