3

A few weeks ago I accidentally changed .bat files to open with Notepad++ (a fairly common issue I believe). On Win XP and Win 7 I had a .reg file that updated the relevant registry keys and sorted out the problem. However, this batch file no longer works for Win 8.1 (I assume file associations are dealt with differently in Win 8.1) and none of my manual registry hacks are working.

No matter what I do, I can't seem to restore .bat files to their previous association. I've finally managed to disassociate .bat files with Notepad++, but I can't figure out how to apply the defaults.

I have tried the solutions listed on the below sites:

http://www.eightforums.com/tutorials/8486-default-file-associations-restore-windows-8-a.html https://social.technet.microsoft.com/Forums/windows/en-US/a85d8a59-b93b-45a3-8aee-cdf93ce32079/how-do-i-reset-the-default-file-association-for-bat-files-on-windows-81?forum=w8itproinstall

Plus I've executed the following commands in an administrator command prompt to no avail (they both report the correct values):

C:\Users\Christopher>assoc .bat
.bat= batfile

C:\Users\Christopher>ftype batfile
batfile="%1" %*

But am not getting anywhere. Can anyone help?

2

This has been a bit of a nightmare, but I have solved it with the help of @Pariah. I had to run the following .reg file as administrator, then manually delete the following key manually:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\UserChoice

Run reg file as admin:

runas /user:administrator "regedit /s c:\test.reg"

Reg file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\batfile]
@="Windows Batch File"
"EditFlags"=hex:30,04,00,00
"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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
  32,00,5c,00,61,00,63,00,70,00,70,00,61,00,67,00,65,00,2e,00,64,00,6c,00,6c,\
  00,2c,00,2d,00,36,00,30,00,30,00,32,00,00,00

[HKEY_CLASSES_ROOT\batfile\DefaultIcon]
@=hex(2):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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,69,00,6d,00,\
  61,00,67,00,65,00,72,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,36,\
  00,38,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell]

[HKEY_CLASSES_ROOT\batfile\shell\edit]

[HKEY_CLASSES_ROOT\batfile\shell\edit\command]
@=hex(2):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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
  54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,25,00,31,00,00,\
  00

[HKEY_CLASSES_ROOT\batfile\shell\open]
"EditFlags"=hex:00,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"

[HKEY_CLASSES_ROOT\batfile\shell\print]

[HKEY_CLASSES_ROOT\batfile\shell\print\command]
@=hex(2):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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
  54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,2f,00,70,00,20,\
  00,25,00,31,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\runas]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\batfile\shell\runas\command]
@=hex(2):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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6d,00,\
  64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,43,00,20,00,22,00,25,00,31,00,22,\
  00,20,00,25,00,2a,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\runasuser]
@="@shell32.dll,-50944"
"Extended"=""
"SuppressionPolicyEx"="{F211AA05-D4DF-4370-A2A0-9F19C09756A7}"

[HKEY_CLASSES_ROOT\batfile\shell\runasuser\command]
"DelegateExecute"="{ea72d00e-4960-42fa-ba92-7792a7944c1d}"

[HKEY_CLASSES_ROOT\batfile\ShellEx]

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers]
@="Compatibility"

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers\Compatibility]
@="{1d27f844-3a1f-4410-85ac-14651078412d}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers\OpenGLShExt]
@="{E97DEC16-A50D-49bb-AE24-CF682282E08D}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\PropertySheetHandlers]

[HKEY_CLASSES_ROOT\batfile\ShellEx\PropertySheetHandlers\ShimLayer Property Page]
@="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"
  • NOT WORKING!!!!!!!!!!!!!!!!!!!! – YumYumYum Jan 17 '19 at 12:04
1

The Final Reg File the user had to use to correct this issue in Windows 8.1 [after running the batch file provided by Notepad++ to set notepad++ as default batch file handler. They tried both of the other fixes below this one. In the end they had to run the following in a .reg file as admin.

FIRST, to run a reg file as admin: Note: It is best to place this file on C:\ and name file something like fix.reg so in the end it is something like C:\fix.reg. If you place this somewhere where the path and/or file name has any spaces included in it you will get an error message and the reg keys will not be added/changed.

The Command:

runas /user:Administrator "regedit.exe c:\fix.reg"

The contents of the fix.reg file:

Windows Registry Editor Version 5.00 

[HKEY_CLASSES_ROOT\batfile] 
@="Windows Batch File" 
"EditFlags"=hex:30,04,00,00 
"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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\ 
32,00,5c,00,61,00,63,00,70,00,70,00,61,00,67,00,65,00,2e,00,64,00,6c,00,6c,\ 
00,2c,00,2d,00,36,00,30,00,30,00,32,00,00,00 

[HKEY_CLASSES_ROOT\batfile\DefaultIcon] 
@=hex(2):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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,69,00,6d,00,\ 
61,00,67,00,65,00,72,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,36,\ 
00,38,00,00,00 

[HKEY_CLASSES_ROOT\batfile\shell] 

[HKEY_CLASSES_ROOT\batfile\shell\edit] 

[HKEY_CLASSES_ROOT\batfile\shell\edit\command] 
@=hex(2):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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\ 
54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,25,00,31,00,00,\ 
00 

[HKEY_CLASSES_ROOT\batfile\shell\open] 
"EditFlags"=hex:00,00,00,00 

[HKEY_CLASSES_ROOT\batfile\shell\open\command] 
@="\"%1\" %*" 

[HKEY_CLASSES_ROOT\batfile\shell\print] 

[HKEY_CLASSES_ROOT\batfile\shell\print\command] 
@=hex(2):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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\ 
54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,2f,00,70,00,20,\ 
00,25,00,31,00,00,00 

[HKEY_CLASSES_ROOT\batfile\shell\runas] 
"HasLUAShield"="" 

[HKEY_CLASSES_ROOT\batfile\shell\runas\command] 
@=hex(2):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,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6d,00,\ 
64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,43,00,20,00,22,00,25,00,31,00,22,\ 
00,20,00,25,00,2a,00,00,00 

[HKEY_CLASSES_ROOT\batfile\shell\runasuser] 
@="@shell32.dll,-50944" 
"Extended"="" 
"SuppressionPolicyEx"="{F211AA05-D4DF-4370-A2A0-9F19C09756A7}" 

[HKEY_CLASSES_ROOT\batfile\shell\runasuser\command] 
"DelegateExecute"="{ea72d00e-4960-42fa-ba92-7792a7944c1d}" 

[HKEY_CLASSES_ROOT\batfile\ShellEx] 

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers] 
@="Compatibility" 

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers\Compatibility] 
@="{1d27f844-3a1f-4410-85ac-14651078412d}" 

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers\OpenGLShExt] 
@="{E97DEC16-A50D-49bb-AE24-CF682282E08D}" 

[HKEY_CLASSES_ROOT\batfile\ShellEx\DropHandler] 
@="{86C86720-42A0-1069-A2E8-08002B30309D}" 

[HKEY_CLASSES_ROOT\batfile\ShellEx\PropertySheetHandlers] 

[HKEY_CLASSES_ROOT\batfile\ShellEx\PropertySheetHandlers\ShimLayer Property Page] 
@="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}" 

[HKEY_CLASSES_ROOT\batfile\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}] 
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

Other Possible fixes to try if above does not work for you [It has been verified to work by at least 1 person where the below did not in Windows 8.1]

Registry key to navigate to: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.BAT\UserChoice Delete the key named "user choice"

Code Block for clarity (per request):

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\UserChoice

Also listed on the reference page as a fix is the following:

I would disagree there. This is not a Windows 8 specific issue. Something has changed the file association, and it needs to be changed back. This same issue can be replicated all the way back to Windows 2000 (and probably earlier). Did you check the following keys and make sure they were set to the values shown, as seen in the responses in that post?

[HKEY_CLASSES_ROOT.bat] @="batfile"

[HKEY_CLASSES_ROOT.bat\PersistentHandler] @="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

[HKEY_CLASSES_ROOT\batfile\shell\open\command] @="\"%1\" %*"

The user of this second more complex solution also has a link to a *.reg file they created which should automagically set those several keys listed above this text for you to the default values. See Bottom of reference page as this was marked as Best Solution and those are kept at bottom of page (why M$ made that decision is beyond me would you not put solutions at top of threads so they are easier to find? Good ol M$)

That should do it and have notepad++ stop taking over. As a side note you can right click a *.bat file and if you click the Edit entry in the menu that will open the batch file in notepad for you while still leaving the double click to execute the batch file in a command shell.

Reference used [Listed in the Windows 7 forum but is the same in Windows 8.1 btw]:

https://social.technet.microsoft.com/Forums/windows/en-US/fc2ca91d-5509-4c9b-92a5-5af19375e361/lost-bat-file-association?forum=w7itprogeneral

More detailed Info (how to open regedit and run as admin if needed)

For this one it is a little tricky since we have to use the Registry Editor. You SHOULD be able to do this as a user since the change is a user level one most of the time, but depending on your security policies in place you may have to do the following.

  1. Click the Start Menu Button
  2. Type in regedit (just start typing when the start menu is visible and it should start searching automatically).
  3. Once you see regedit appear on screen right click on it
  4. When you see the context menu appear click on Run as Administrator
  5. Authenticate (type in your administrator password, place finger on fingerprint reader however you have it setup it's like logging in to the account)

Side Note: You can try it first without doing the administrator part if you would like. The worst thing that it will do is deny your ability to delete the key listed. If this happens you must run as administrator and you will then be able to delete it.

Generally for MOST file associations in almost all versions of Windows (aside from system set ones such as batch files):

All you should have to do is hold the LEFT Shift Key down while you right click on a *.bat file. When you do this to a file you should see an Open With ... option appear close to the top of the context menu that appears [the small menu that you get when you right click on things]. Once you click open with you will get a dialog where you can choose what to open the file with. If you check the Use as default box in lower left corner it will become the new default action when you double click files of the same type.

  • Oh and the reason the admin console reports the right value is it is giving what the administrator username itself has set. Since this was a user level change it would only be affecting your specific account while any other accounts should have the system default action. – Pariah Jan 22 '15 at 15:37
  • Unfortunately your answer just replicates what I've already tried. I do not have a UserChoice key in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat as I have already deleted it. – Spikeh Jan 22 '15 at 15:50
  • Be sure to review answer I was adding the second more complex solution at the time you were reading this it seems. The block quoted info should fix you up if the first original solution did not. – Pariah Jan 22 '15 at 15:51
  • as far as I can see it should be good now cleaned up the accidental extension of the block quote and otherwise everything should be clear and clean – Pariah Jan 22 '15 at 15:53
  • You are right on the code block for reg key maybe I will add it as a second entry lower in the doc, but I was using it as part of the title and that is why it did not get blocked. I did not specifically go to hotlink it all I did was paste the URL in and it shows as a clickable link with full URL [so folks can know where it goes instead of shortening it I like knowing full URLs so I try to be courteous to others – Pariah Jan 22 '15 at 16:02
0

Deleting this registry key (as an admin) was missing from all the above (Windows 8.1):

HKEY_CURRENT_USER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts.bat\UserChoice.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.