This week I came across the following question, which I'd like to share with you:

Any file on my computer that ends in .gif gives the message "Access is denied." when I try to open it. If I rename the file to .jpg or something else, it opens fine (though that's not a good thing to do, obviously). Any other image file opens fine, and if I rename one of them to .gif and try to open it, I get "Access is denied." And it's not just image files. Any file that opens with no problem, when renamed to .gif and opened, results in "Access is denied."

The file association information for .GIF file type is given below by the asker.

[HKEY_CLASSES_ROOT\.gif]
"PerceivedType"="image"
@="giffile"
"Content Type"="image/gif"

[HKEY_CLASSES_ROOT\.gif\OpenWithProgids]
"giffile"=hex(0):

[HKEY_CLASSES_ROOT\.gif\PersistentHandler]
@="{098f2470-bae0-11cd-b579-08002b30bfeb}"

[HKEY_CLASSES_ROOT\giffile]
@="GIF Image"
"BrowserFlags"=dword:00000008
"EditFlags"=dword:00010000
"FriendlyTypeName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,\
00,6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
32,00,5c,00,73,00,68,00,69,00,6d,00,67,00,76,00,77,00,2e,00,64,00,6c,00,6c,\
00,2c,00,2d,00,33,00,30,00,32,00,00,00
"ImageOptionFlags"=dword:00000003

[HKEY_CLASSES_ROOT\giffile\CLSID]
@="{25336920-03F9-11cf-8FD0-00AA00686F13}"

[HKEY_CLASSES_ROOT\giffile\DefaultIcon]
@="shimgvw.dll,2"

[HKEY_CLASSES_ROOT\giffile\shell\open]
@="Animate"

[HKEY_CLASSES_ROOT\giffile\shell\open\command]
@="\"D:\\Program Files\\msgif\\GIFAnimator.exe\" \"%1\""

[HKEY_CLASSES_ROOT\giffile\shell\open\ddeexec]

[HKEY_CLASSES_ROOT\giffile\shell\open\ddeexec\Application]
@="shimgvw"

[HKEY_CLASSES_ROOT\giffile\shell\open\ddeexec\Topic]
@="System"

[HKEY_CLASSES_ROOT\giffile\shell\Paint]

[HKEY_CLASSES_ROOT\giffile\shell\Paint\command]
@="\"%SystemRoot%\\System32\\mspaint.exe\" \"%1\""

After examining the settings carefully, I spotted atleast one error in the GIF file association setting.

[HKEY_CLASSES_ROOT\giffile\shell\Paint\command]
@="\"%SystemRoot%\\System32\\mspaint.exe\" \"%1\""

In the above key, the (default) value type is REG_SZ, but the existing data contains expandable values / environment strings. If you need to use expandable values such as %Windir%, %Systemroot% etc, you should use the REG_EXPAND_SZ value type.

The "Access is denied" error was then resolved by changing the above entry (into already expanded format) directly in the registry.

"%SystemRoot%\System32\mspaint.exe" "%1"

becomes

"C:\Windows\System32\mspaint.exe" "%1"