What is the purpose of the "desktop.ini" file in Windows and how can I keep it from being generated?

7

5

It's not a big problem, but I'm comparing a lot of directories and desktop.ini keeps throwing off the total file size and file count. How can I make Windows stop generating it, and what does it do?

Fred Hamilton

Posted 2009-08-23T00:07:58.483

Reputation: 2 010

Answers

7

I found the answer: You can stop auto-generating desktop.ini files by unchecking "Remember each folder's view settings" in the Folder Options/View (or similar) settings. While this will not allow each folder to have its own unique size, view mode, etc., that's fine with me because I want all my folders to look and behave the same way.

"Hide protected operating system files" may treat the symptoms sometimes, but is not really a solution, because while the Windows OS may know to hide the files, other software (duplicate finding/synchronization, other OS's when this disk is shared) may not.


In Windows 7, this should work:

  1. Open the registry editor (Start → type regedit → hit Enter)
  2. Navigate to the following key:
    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
  3. Add a DWORD value UseDesktopIniCache (if it doesn't exist yet), and set its value to 0 (zero)

Source: Nevermore Be Bothered by Desktop.ini

Fred Hamilton

Posted 2009-08-23T00:07:58.483

Reputation: 2 010

1This option is not there in Windows 8 and Windows 7. Any alternative? – Ashwin Nanjappa – 2012-09-12T14:02:46.533

Ah, this is good to know! I've had two desktop.ini files sitting on my desktop for some time, and never got around to figuring out if they were safe to delete. – SaintWacko – 2012-09-12T14:04:07.747

@SaintWacko For the record, the reason you have two is because the "desktop" you see is actually a union combination of your user's "Desktop" folder and the "Desktop" folder belonging to all users. Things placed in the former appear to you only and things placed in the latter appear to every user. – Bob – 2013-10-21T14:17:07.530

7

It keeps the preferences for the layout of that folder. If there is any deviation from the standard layout of a folder, then a desktop.ini is created. You can hide it by selecting the "hide protected operating system files" option in windows explorer.

MDMarra

Posted 2009-08-23T00:07:58.483

Reputation: 19 580

I appreciate the answer, but I really wanted to know how to stop generating it in the first place. I already know how to hide it; I'd rather it not exist to begin with. I'd rather stop litter than hide it! In the end I figured it out (see my answer). – Fred Hamilton – 2009-08-23T17:42:19.137

2It's not litter if it serves a purpose. Most sync or compare software can have exclusions added to avoid certain files. Glad you figured it out. – MDMarra – 2009-08-23T18:11:00.687

2

desktop.ini stores information about "special" qualities for folders, such as fancy icons, or displaying the file listings in a different way from default. It's harmless, and really I'd reccomend just subtracting one ;)

Phoshi

Posted 2009-08-23T00:07:58.483

Reputation: 22 001

Thanks for the response, but when I'm trying to determine if two directories are the same (to the first order with good accuracy - I know this is not fool-proof), the byte count is a pretty good indicator. Desktop.ini can mess this up, and I don't want to have to manually check if desktop.ini exists, then if it does, subtract its byte count from the total. – Fred Hamilton – 2009-08-23T17:39:56.630

1

The desktop.ini file is an actual file, and as such will count as a file, and will take up space on your disk. Your only possible way of avoiding such files from being created is to have very standard folders all accross the board, and if a folder does not deviate at all from the standard, the desktop.ini file may not have to be created. If it shows up in the existing counts, although you have not modified the file's attribute, there is nothing that you can do. However, if your default folder display config is to show all hidden and system files, that may explain why. Try turning this option off in Explorer, and see whether it makes a difference. This also depends on what you use to perform the file count. If you only use the standard Windows Explorer, that's the way of doing it. Otherwise, it depends on what you use to perform the file count.

jfmessier

Posted 2009-08-23T00:07:58.483

Reputation: 2 530

0

In Windows 7, if a folder is set as Read-only it will not store any setting changes, so no desktop.ini file will be created. This is a means of altering the behaviour of a particular folder, without making a system-wide change affecting the entire computer.

Attributes of folders can be changed on the command line:

ATTRIB  +R  C:\DummyPath\FolderName  

This change can't be made using Windows Explorer.

In Explorer, if you click "Apply changes to this folder only" the attribute is changed for all the files in the folder, but the attribute is not changed for the folder itself.

If you click "Apply changes to this folder, subfolders, and files" the attribute is changed for all files in the folder and all files in its subfolders, but the attribute is still not changed for the folder itself.

Ed999

Posted 2009-08-23T00:07:58.483

Reputation: 178