Troubleshooting – Home folders are displayed as “Documents” or “My Documents”

Client of mine asked me to figure out why is it some of the user Home folders are displayed as “Documents” or “My Documents”?:
B1 B2

First view is presented when looking in the root folder from Windows 2003, second – when looking from Windows 7 or Windows 2008. Interesting isn’t it.

The cause of this behaviour is literally hiding in the folders – desktop.ini file. Hidden desktop.ini is a customization/personalization file. Every folder with corrupted name had a desktop.ini in it.

There are many different aspects that can be controled with desktop.ini, check this article –

In my case the content was following:


First line is changing the name, rest are changing the icon.

OK, so now we know how the name has been changed, but how did they get there?
This is the default Windows7 setting located here [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{FDD39AD0-238F-46AF-ADB4-6C85480369C7}]:

The file is being created with the end user credentials according to the registry settings. If you remove the file it will be recreated after some time.

One of the options is to create our own desktop.ini file and restrict the Modify permission. This option is going to be explained here, but there is one negative aspect that you should be aware off – this might slow down user logon!!! Tracing has showed that Windows is accessing/modifying desktop.ini at user Logon.

So, I’ve created an empty desktop.ini file and gave Full Control only to the local Administrators and SYSTEM account:


Users have no access to modify the file or create the file with the same name.
You might also want to disable inheritance and set owner to Administrators.

New desktop.ini file needs to be distributed to all impacted users. Let’s automate this distribution. Robocopy should do the job as it has a very useful switch – /SEC, it copies files with preserved Security settings.

Here is a script:

@echo off
REM There are several prerequisites before you can use this script.
REM 1. prepared desktop.ini file must be located in C:\Temp folder;
REM 2. this bat file must be in the folder that stores user home folders;

echo %DATE% %TIME% >> desktopini_log.txt
echo. >> desktopini_log.txt
echo Total Copied Skipped Mismatch FAILED Extras >> desktopini_log.txt

Set _date=%DATE:/=-%_%random%
echo Date: %_date%
echo Processing Folders:

for /d %%d in (*) do (
 echo %%d
 echo %%d >> desktopini_log.txt
 If Exist "%%d"\desktop.ini (
  CACLS "%%d"\desktop.ini /E /G "Administrators":F
  attrib -h -s "%%d"\desktop.ini
  rename "%%d"\desktop.ini desktop_backup_%_date%.ini
  attrib +h +s "%%d"\desktop_backup_%_date%.ini
  robocopy C:\Temp\ "%%d" desktop.ini /SEC | findstr "Files" >> desktopini_log.txt

echo The End >> desktopini_log.txt
echo. >> desktopini_log.txt
echo Completed. Check the script execution log file - desktopini_log.txt !!!

Few words about the script:

  • Cacls utility is used to assign local Administrators full control [this is needed in case existing desktop.ini has custom security settings];
  • Attrib utility is used to unhide desktop.ini file, as the rename utility can only operate with visible files;
  • Rename utility creates a backup file in case you would want to restore the previous file.

Leave a Comment here

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s