Question

Can't delete user profile of deleted domain account

Asked by: Barwa

A certain user has been deleted from AD (Windows server 2003 environment)
This user has a profile on several systems across the network

The path of the user profile shows as normal under C:\documents and settings\..... but it shows as "Account Unknown" under user profile settings

See below image

Now we need to delete similar user profiles ( I know that we could simply delete the parent folder that belongs to such user) but I need to do that systematically to remove all possible entries

Regards

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-08 at 02:20:22ID24881417
Topics

Active Directory

,

Windows 2003 Server

Participating Experts
4
Points
500
Comments
14

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Account unknown - user profile!!!!
    PC Model: Win2K Prof. with SP3 + Office 2000 Prof with SP2. Problem: I create user name " A " for example in local machine with Administrator right. The problem is when I try to copy Admin profile to user profile (Default user) I see the account turned to " ...
  2. Roaming Profiles on Workgroup
    I have a question about roaming profile on WORKGROUP. Now, this concept clearly makes sense on a domain setting, but maybe not on workgroup in my opinion, which is why I ask here for clarification. The reason this concept make sense on domain is that, a domain user account c...
  3. unknown account / profile user deleted
    I recently acquirred my old computer from my parent company. As requested i went to the system settings and changed the domain from "CORP" to a workgroup and restarted the computer. In doing so Windows 2000 professional would not accept my old password nad I had t...
  4. Batch file to delete "Account Unknown" profiles
    Hi experts, I've been working on a batch file for doing automatic maintenance on all of 495 XP machines. However I have come across a tough problem for myself in automatically deleting the "Account Unknown" profiles on computers (due to them leaving the company or ...
  5. User Profiles (Roaming)
    I have noticed that on some stations in my domain users profile directories are name simply their username for example bob smith's local profile is name bsmith however on another station if Bob logs in his profile is created in a directory name bsmith.domain . Why is there a...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Seth_McCauleyPosted on 2009-11-08 at 02:32:01ID: 25770054

Even with that profile listed, the user should not be able to log into the computer. A user profile left over from a deleted domain account should not be an issue, except for the space it takes up on the machine. Is that the issue you are concerned with?

 

by: BarwaPosted on 2009-11-08 at 02:49:12ID: 25770090

Thank you , I know that he can't logon as the account does not even exist on Active Directory anymore
Its not only the space that concerns us , its the user profile and its related settings across the system

I know that we could simply delete the folder , if that is all that is required then why is the "user profile" delete option included as per the last image?

 

by: moodjbowPosted on 2009-11-08 at 03:58:58ID: 25770210

Hi Barwa.
The "unknown users" seen in the gui are "mapped" through the registry HKU\<SID> where SID is unique for every local and doman account. Since you do not know the domain SIDs of the deleted accounts you can simply search for some familiar path (ie. under XP C:\Documents and Settings\<domainusername>) - and delete the whole SID-tree.

 

by: oBdAPosted on 2009-11-08 at 03:59:10ID: 25770212

The "Delete" button will not only remove the profile folder, but the user's profile location entry under "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList".
The button is very probably disabled because there are still handles open to the old profile. Reboot the machine, log on with an administrative account, try again to delete it.
Note that the W2k3 Resource Kit Tools contain the "delprof.exe" utility to delete profiles from the command line, including remote profiles. Use the /P argument to avoid deleting profiles you might still need ...
Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

 

by: Seth_McCauleyPosted on 2009-11-08 at 05:55:51ID: 25770461

Settings specific to these users should not affect anyone else on the system. This includes per user registry hives, as it they are stored in each user's folder under "Documents and Settings" (in NTUSER.DAT). Deleting the user's folder from "Documents and Settings" should suffice in most cases. Once their folder is deleted (or at least their NTUSER.DAT file) they will disappear from the list in the "User Profiles" dialog... although this does not remove them from the "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" registry key.

If you would like to automate the deletion of user profiles that do not exist on the domain, I've attached a batch file that will accomplish this. WARNING! This script has no way of knowing if these users are former domain members, so it will prompt you to delete ANY local profile folder. System folders such as All Users, Default User, Administrator, etc. will be automatically ignored. If needed, I also have a version of this script that will instead select disabled domain accounts.

This script could be easily modified to not prompt for user input, making it much more efficient than delprof. However, I highly recommend testing it out before doing this. I have the actual delete command commented out, so when you first run it you will only be shown what profiles it will find. Thoroughly test this in your environment (with the delete command disabled) before using it to delete user profile folders.

@echo off
setlocal enabledelayedexpansion
cls
echo.
echo WARNING! This script will prompt you to delete user folders for ANY user
set /p UserInput=  not found on the domain. Are you sure you want to proceed^? ^(Y/N^): 
if /i "%UserInput%" equ "y" goto Start
goto End 
:Start
echo.
echo Searching for local user accounts, please wait... 
for /f "tokens=*" %%i in ('dir /a:d /b "%SYSTEMDRIVE%\Documents and Settings" ^| find /v /i "Administrator" ^| find /v /i "All Users" ^| find /v /i "Default User" ^| find /v /i "LocalService" ^| find /v /i "NetworkService"') do (
	for /f "tokens=1-20" %%I in ('net user %%i /domain 2^>^&1^| find /i "The user name could not be found."') do (
		echo.
		echo The user account "%%i" does not exist in Active Directory.
		set /p UserInput=Would you like to delete this user's local profile? ^(Y/N^): 
		if /i "!UserInput!" equ "y" (
			echo.
			echo Removing user account for user "%%i"...
			echo ^(With profile deletion enabled, the following folder would be deleted:
			echo  "%SYSTEMDRIVE%\Documents and Settings\%%i"^)
			REM Uncomment the following section to enable deleting user profiles:
			REM if "%%i" neq "" rmdir /s/ q "%SYSTEMDRIVE%\Documents and Settings\%%i"
		)
	)
) 
:End
echo.
echo Press any key to exit...
pause>NUL
endlocal
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:

Select allOpen in new window

 

by: BarwaPosted on 2009-11-08 at 10:09:28ID: 25771233

Since these profiles of the "deleted user accounts" are no longer required , I am following a 2-step approach as follows:

  1. Delete the related registry entries as per oBdA comments above 
  2. Delete the folder tree of each user under c:\documents and settings 
The first step was executed normally on one machine for two profiles and the related entries have automatically disappeared from the list of accounts displayed in my first post

While attempting to delete the folder on the C: drive , I received the following error message:


 

by: oBdAPosted on 2009-11-08 at 10:13:38ID: 25771243

That's what I said above: there are still handles into the user's profile folder open, which is why the "Delete" option was disabled, and why you can't delete the folder now.
Reboot the machine, try again.

 

by: Seth_McCauleyPosted on 2009-11-08 at 10:27:09ID: 25771288

Yes, Windows has a nasty habit of not fully unmounting registry hives at logout (due to open application handles as oBdA suggested). Although this will not help with the computers you are currently trying to cleanup, Microsoft's "User Profile Hive Cleanup Service" will can help you avoid this in the future. Once installed, it monitors and automatically terminates open application handles at logout (in order to properly unmount the user's registry hive).

http://www.microsoft.com/downloads/details.aspx?FamilyId=1B286E6D-8912-4E18-B570-42470E2F3582&displaylang=en

 

by: BarwaPosted on 2009-11-08 at 11:11:45ID: 25771461

The machine was rebooted several times during the last 30 days

I have already used Process Explorer from Sysinternals to check if any processes are running under any of these accounts but nothing was found

 

by: Seth_McCauleyPosted on 2009-11-08 at 12:10:13ID: 25771676

I've seen this happen before. I didn't think the "User Profile Hive Cleanup Service" would help you this time, because I assumed a reboot would fix it. Try installing it (you'll may need to restart again after installation in order for it to work).

If that doesn't work (or if you prefer an alternative), perhaps there is something running at startup from their user profile for some reason. Try this: show hidden files and protected system files, open up that users profile folder, then delete everything you can (most likely everything but "NTUSER.DAT" and "ntuser.dat.LOG"). Now restart, and you should be able to fully delete the user's profile.

While this could be a major hassle to do individually on each computer, deleting all possible files for a specific user fairly simple to do in a batch file:

@echo off
set UserFolder=
set /p UserFolder= Enter the login name of the user you wish to delete:  
:: Check to make sure a user account gets specfied. This is done to ensure
:: that the entire "Documents and Settings" folder does not get deleted.
if "%UserFolder%" equ "" goto :EOF
if "%UserFolder%" equ "." goto :EOF
if "%UserFolder%" equ "\" goto :EOF
if "%UserFolder%" equ "/" goto :EOF 
rmdir /s /q "%SYSTEMDRIVE%\Documents and Settings\%UserFolder%"
echo.
echo Done. 
echo.
echo Press any key to exit...
pause>NUL
set UserFolder=
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:

Select allOpen in new window

 

by: oBdAPosted on 2009-11-08 at 13:53:25ID: 25772109

Did you ever try to load this user's hive into regedit, and then forgot to unload it again?
Is the Delete button available when you're logged on using another administrative account?

 

by: moodjbowPosted on 2009-11-09 at 08:10:10ID: 25777161

I remember also cases where the NTUSER.DAT was as if opened and even sysinternals could not find any  handles adressing the file.
BUT what I remember was beong used long time ago to change some open handle files was renaming them. Something like REN NTUSER.DAT NTUSER.BAK?
If it works at this point the handle is still open to the renamed file but after restart it should definitely not "catch" the new name anymore

 

by: BarwaPosted on 2009-11-15 at 21:41:57ID: 31651528

Partially

 

by: simoneadyPosted on 2010-01-21 at 04:25:32ID: 26369261

Its been a while since I came across a problem like this but if I recall correctly we were able to go in to safe mode and remove whatever profile we needed to delete via the usual method under profiles.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...