36

I would like to stop the 'desktop.ini' file being created on the 'Desktop' of my windows 10 machine. I have asked this question sepcifically about Windows 10: There is a question about the same issue on Windows 8 here, the solutions proposed there (and elsewhere) for Windows 7 and 8 don't seem to work.

Please, no solutions along the lines of 'disable viewing hidden files'. My specific question is how to stop the file being created on the desktop.

Neil Townsend
  • 559
  • 1
  • 4
  • 10

5 Answers5

8

(Much) Later edit: It appears that this solution doesn't work on Windows10 anymore. Leaving the answer here for reference.


I used the solution found here:

  • Press Win+R and enter regedit
  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
  • Edit / create new DWORD: UseDesktopIniCache with the data 0

For me, I didn't have the value, so I had to create it. After restart, it automatically created the value in HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies\Explorer

Running Windows 10 Build 14393.222

tlex
  • 81
  • 1
  • 3
  • 1
    Please read [How to reference material written by others](http://superuser.com/help/referencing). You should block quote text that has been written by some else. See [Markdown help](https://superuser.com/editing-help). I've fixed it for you this time, but please pay attention to this in future. – DavidPostill Oct 02 '16 at 17:57
  • 2
    Hi, afraid this doesn't work on my windows 10 system, running latest version of 10. But thanks for trying, appreciate it. – Neil Townsend Oct 26 '16 at 10:31
-1

*Updated script. Experimental Inheritance safe script. This will not destroy usability of your desktop. Anyone who already lost inheritance run

ICACLS "C:\Users\<username>\Desktop" /reset /t 

to get back full functionality.


It is not possible to prevent Windows from creating desktop.ini because it is not actually Windows that is doing it. Some other third-party service is triggering the creation of that file, and clearly, Windows allows that in spite of UseDesktopIniCache=0.

Desktop.ini was driving me insane so I came up with a ragtag solution. I observed that the desktop.ini file gets created a few seconds after boot. I took advantage of that. Using Task Scheduler, I temporarily disable write permission on Desktop upon boot. That stops third-party services from performing shenanigans with my desktop. Then one minute after boot, another task reinstates write permission on Desktop.

Here I have shared a set of sample XML files for Task Scheduler to do the job.

This one is for disabling write permission on boot:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2018-01-09T18:21:14.9818893</Date>
    <Author>spero_LAPTOP\spero</Author>
    <URI>\Desktop Write Permission disable</URI>
  </RegistrationInfo>
  <Triggers>
    <LogonTrigger>
      <ExecutionTimeLimit>PT1M</ExecutionTimeLimit>
      <Enabled>true</Enabled>
    </LogonTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>##################################</UserId>
      <LogonType>Password</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>true</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT1M</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>ICACLS</Command>
      <Arguments>"C:\Users\spero\Desktop" /deny "spero":(WD)</Arguments>
    </Exec>
  </Actions>
</Task>

This one is for reinstating the permission a minute later:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2018-01-09T18:19:03.2968461</Date>
    <Author>spero_LAPTOP\spero</Author>
    <URI>\Desktop Write Permission</URI>
  </RegistrationInfo>
  <Triggers>
    <LogonTrigger>
      <ExecutionTimeLimit>PT1M</ExecutionTimeLimit>
      <Enabled>true</Enabled>
      <Delay>PT1M</Delay>
    </LogonTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>######################################</UserId>
      <LogonType>Password</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>true</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT1M</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>ICACLS</Command>
      <Arguments>"C:\Users\spero\Desktop" /grant "spero":F /r</Arguments>
    </Exec>
  </Actions>
</Task>

Please note that my boot drive is an SSD, albeit not a very fast one. The timings might vary depending on how fast your OS boots.

Also, you can't import these scripts directly because of the presence of Author and User ID fields. You need to manually replace those with proper values. The Author is simply computername\username. The UserId for the currently logged in user can be obtained by opening a Command Prompt and entering wmic useraccount where name='%username%' get sid. The first line of the response will be SID, the next line will look something like X-#-#-##-##########-##########-##########-#### - that's your UserId. And replace "spero" with your username.

You need to save this as an xml file, then import it from Task Scheduler.

Spero
  • 107
  • 5
  • **Update:** After using the above solution for a bit, and having to deal with a thousand "You don't currently have permission to access this folder" messages which turned out to be a bigger bother than the desktop.ini files, now I recommend changing the command to ICACLS "C:\Users\Spero\Desktop" /deny "Administrators":(WD). I have updated the above script accordingly. – Spero Jan 31 '18 at 10:09
  • This is completely incorrect: "because it is not actually Windows that is doing it" – NetMage Aug 27 '20 at 21:56
  • @NetMage I would be interested to see if you can reproduce this behaviour in a fresh windows installation. Steps? – Spero Sep 23 '20 at 17:27
-2

[Deleted prior answer] Whoops, sorry about that. Its been awhile and had it confused with thumbs.db

Try this instead for desktop.ini files: Open the registry editor and navigate to: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer Change UseDesktopIniCache value to 0 (Add it as a DWORD value if it doesn't already exist.

Here are a couple links to other's posts where it was working for them. Most were with win 7 and 8 however.

Thor
  • 1
  • 2
-5

It is best not to delete the desktop.ini file, as the folder requires the .ini file to run properly. A Desktop.ini file is a file that determines the way a folder is displayed by Windows. If you do want to however, enable view hidden files and right-click and press delete to delete the item.

potatoman
  • 313
  • 1
  • 2
  • 14
  • 6
    I have hidden files viewable all the time. I regularly delete this file and everything works just fine. But after a while it is re-created. As per the question, I want to stop it being created. How do I do this? – Neil Townsend Nov 28 '15 at 11:06
  • 1
    The answer is correct. Its a system file performing a system function. Windows re-creates it because it knows it should have it. Your solutions are: Hide it. Ignore it. Petition MS to radically change the OS in the next release or stop using Windows. – Linef4ult Nov 28 '15 at 11:41
  • 6
    While that's the official line `deleting it may cause the folder to be problematic` it's also misleading. Can you name *one* ill effect if deleting desktop.ini? – dxiv Nov 28 '15 at 18:41
  • Did some more research, no ill affects, but it's best to leave it alone. – potatoman Jan 10 '17 at 01:27
  • If there's no ill effects, then it's NOT best to leave it alone, as leaving it alone DOES have ill effects. – TelFiRE Sep 13 '22 at 06:17
-5

I know you said "stop it from being created". I assume that is because you want system files to be visible and desktop.ini (and probably thumbs.db) simply not present. The following solution doesn't stop it from being created, but it hides system files on your desktop only, not system-wide. Perhaps that would be acceptable.

  • Select "Desktop" in Windows Explorer
  • Click the "View" tab
  • Uncheck “Hidden items” under “Show/hide” in the ribbon

I got this solution here: http://searchenterprisedesktop.techtarget.com/blog/Windows-Enterprise-Desktop/Settings-Reset-in-Windows-10-Reinforces-Desktopini-Trick

  • 1
    However, despite what the article says, that also stops hidden items from being visible everywhere. It is a system wide switch, at least when I tried it! – Neil Townsend Jun 08 '16 at 13:49
  • 1
    @GollyRojer .. down-voted your "answer" because you don't fully understand the issue. All you've proposed is to HIDE something, not actually stop the OS from creating them. Additionally, your suggestion causes issues for those that have taken steps explicitly to show all files. Hiding them, is akin to sweeping a pile of dirt under the carpet. out of view, but the dirt is still there. – TG2 Apr 23 '17 at 21:19
  • TG2, did you even read my post? There's some lack of understanding going on here, but it isn't on my part. – GollyRojer Mar 31 '18 at 05:23