*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.
UseDesktopIniCache=0
(from the reply at superuser.com/a/650431/523828) not work in Windows 10?