"Windows can't open this file" for .appref-ms extension

3.6k views Asked by At

I'm trying to run a ClickOnce installer and I get this useless error message from Windows 7: "Windows can't open this file".

The file extension is .appref-ms

Has anyone seen this or have any advice?

Windows can't open this file appref-ms

1

There are 1 answers

0
Dan On BEST ANSWER

I had this issue on a client's machine. It appears that the operating system does not know the correct association for the file extension, but in reality .appref-ms is not a normal extension and is not directly associated with any program.

I found the following page eventually:

https://social.msdn.microsoft.com/forums/windows/en-us/9ff7867c-7e57-468c-a632-762a76f66f6d/windows-7-64-bit-unable-to-open-apprefms

This contains some information on restoring potentially damaged registry keys, which can cause this issue. However, in my opinion it gives the wrong advice to associate dfshim.dll with .appref-ms. When I did this, it created an association to that dll in the registry, but upon checking the registry of a working machine, no such association exists. This association also causes .appref-ms files to lose their application specific icons, and display instead this icon: dfshim.dll icon

In addition, this association did not actually launch my application successfully, but for some others it may actually work (I don't know).

The correct solution is to restore even more registry keys, which cascade to allow windows to treat .appref-ms files more like applications than files to be opened with programs. The necessary keys are below (I may have overzealously included a couple that are not strictly necessary, but at least some of them are):

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.appref-ms]
@="Application.Reference"

[HKEY_CLASSES_ROOT\.application]
"Content Type"="application/x-ms-application"
@="Application.Manifest"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Reference\shell]
@="open"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Reference\shell\open]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Reference\shell\open\command]
@="\"C:\\Windows\\System32\\rundll32.exe\" \"C:\\Windows\\System32\\dfshim.dll\",ShOpenVerbShortcut %1|%2"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Manifest\shell]
@="open"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Manifest\shell\open]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Manifest\shell\open\command]
@="\"C:\\Windows\\System32\\rundll32.exe\" \"C:\\Windows\\System32\\dfshim.dll\",ShOpenVerbApplication %1"

This appears to apply to both .application and .appref-ms type files. The first key identifies .appref-ms as class "Application.Reference". The later key under "Classes\Application.Reference" defines how these types are launched. These are not simple "open with" associations that Windows is trying to help you create (and which will be created under HKCU instead of HKLM).