Skip to content

Instantly share code, notes, and snippets.

@hyrious
Last active May 10, 2024 00:10
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hyrious/aa87fe5c4161da438b50af84288ee873 to your computer and use it in GitHub Desktop.
Save hyrious/aa87fe5c4161da438b50af84288ee873 to your computer and use it in GitHub Desktop.
restore desktop.ini if some guy messed them up

Take %UserProfile%\Desktop\desktop.ini for example.

  1. Create a desktop.ini file with content below and saved in UTF-16 LE with BOM. Hopefully notepad.exe has such choice to use the right encoding.
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21769
IconResource=%SystemRoot%\system32\imageres.dll,-183
  1. Change desktop.ini's attributes to +A +S +H (Archived, System, Hidden)
attrib +A +S +H %UserProfile%\Desktop\desktop.ini
  1. Change %UserProfile%\Desktop folder's attributes to +R (Read-only)
attrib +R %UserProfile%\Desktop
  1. Restart explorer.exe

Debug

If it doesn't work, try attrib +S %UserProfile%\Desktop.

Default folders' desktop.ini

Documents

[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21770
IconResource=%SystemRoot%\system32\imageres.dll,-112
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-235

Pictures

[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21779
InfoTip=@%SystemRoot%\system32\shell32.dll,-12688
IconResource=%SystemRoot%\system32\imageres.dll,-113
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-236

Downloads

[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21798
IconResource=%SystemRoot%\system32\imageres.dll,-184

Favorites

[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21796
IconResource=%SystemRoot%\system32\imageres.dll,-115
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-173

Links

[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21810
IconResource=%SystemRoot%\system32\imageres.dll,-185
DefaultDropEffect=4
[LocalizedFileNames]
Desktop.lnk=@shell32.dll,-21769
Downloads.lnk=@shell32.dll,-21798

Music

[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21790
InfoTip=@%SystemRoot%\system32\shell32.dll,-12689
IconResource=%SystemRoot%\system32\imageres.dll,-108
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-237

Videos

[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21791
InfoTip=@%SystemRoot%\system32\shell32.dll,-12690
IconResource=%SystemRoot%\system32\imageres.dll,-189
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-238
@120318
Copy link

120318 commented Aug 28, 2021

Thanks!

@gutenfries
Copy link

gutenfries commented Feb 18, 2022

Update: These are no longer accurate for windows 11.

I admittedly do not know what the certain indexes are, as evidenced by my delving into these threads, but the resources for Documents are incorrect.

the following is valid for Windows 11, however, I still haven't been able to figure out the icon index for IconResource.

[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21773
IconResource=%SystemRoot%\system32\imageres.dll, <no idea>
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-235

The Windows 10 icon is available in Windows 11 via index 184, i.e.

IconResource=%SystemRoot%\system32\imageres.dll,-184

obviously, this icon doesn't quite match the others, but until I or someone else messes around enough to find the correct one, this will at least do.

@Jamesstevens-3rd
Copy link

@gutenfries
Copy link

Why don't we have a reaction button for gists yet?

anyway, thumbs up, thank you for contributing this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment