How to fix Windows Batch file association on Server 2008.
Somehow my .bat file association got set to “Windows Batch File” instead of “Unknown Application”. This resulted in the batch file opening a command prompt window upon double-clicking the icon. Running the batch file from the command line worked fine, just the double-click action was going sideways.
After looking into multiple (3+ days) searches on the Interwebs with no success, I came across one tidbit of information from a Lockergnome forum. http://help.lockergnome.com/windows/BAT-File-Association-Broken–ftopict514456.html
Also look for the key;
and delete the key named
Following the thread and seeing that all my assoc and ftype commands were correct, Dave Patrick references a single registry entry that lead me to the answer. According to the thread, users deleting this key said it works for them. This may still be true, but they were working on XP and Vista.
Being that this was Windows Server 2008R2, I didn’t want to take a scorched earth policy to this problem, potentially cause more problems and ultimately not know if a simpler fix would suffice. So I decided to investigate that key further. By comparing that registry key from a working Server 2008 install against the non-working Server 2008 install, I figured out what minor changes make the batch file process the double-click action properly.
The extra UserChoice key with Progid: Applications\cmd.exe that was overriding the default handling of batch file execution upon double-click actions.
Solution to my issue was to delete the two extra items in OpenWithList (a and MRUList), and delete the entire UserChoice key from under the .bat key. Removing the UserChoice key would most likely correct the issue at hand, but just to ensure completeness, I removed the extra references in the OpenWithList key.
Note: The icon displayed in Windows Explorer looked like the C:\ prompt. Another clue that it wasn’t right. The correct icon should look like two gears, one larger than the other. After deletion of the above keys, the default icon was also reset to the two gears.