What do I set the 'Opens with...' property to in order to get the system to run .bat files again (when they are double-clicked)?

Somehow my boss convinced his workstation that the handler for .bat files was supposed to be Word. Now, when double-clicking .bat files, they're opened up in Word.

  • 1
    I can't even find .BAT in the file type associations dialog in Windows. And I can't invoke the Open With... dialog on a .bat file. How could he have changed it?? – Nick Bedford Oct 9 '09 at 1:03
  • 3
    umm...i'm guessing that's why he's da boss? ;) – justSteve Oct 9 '09 at 1:12
  • 3
    right click .bat file -> Open with... -> select MS Word, check "Always open with this program", click OK. bam, your extension is now registered to Word. – quack quixote Oct 11 '09 at 17:21
  • My bat files also don't have the "Open With" menu (Windows 7) Other files have it, of course. – lbalazscs Jan 16 '13 at 18:12
  • 1
    FYI, .bat files are not executables. They are interpreted scripts. – Keltari Jan 17 '16 at 5:55

11 Answers 11


I think you'll have to remove the .bat file association from the registry (using the regedit program).

According to this forum thread on LockerGnome, you need to remove registry settings underneath this key:


You'll probably want to back up registry before doing this, just to be safe.

  • 30
    For you minimalists out there, I would add that I was successful by removing only the UserChoice subfolder. Once it was gone, the default Execute behavior was restored. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat\UserChoice – Mark F Guerra Apr 25 '13 at 17:11
  • I removed the entire .bat key and things came back to normal. For some reason (I suspect antivirus) I couldn't rename the UserChoice key. – Kim Gräsman Jul 1 '14 at 6:10
  • Such a pain!! and this happened automatically on an update. Thanks a bunch MS. – Jus12 Jul 28 '15 at 13:28
  • In the path HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat I removed the UserChoice key completely, which worked fine for me. @Kim - maybe you did not run regedt32 as administrator (right-click and select Run as administrator)? – Matt Oct 9 '15 at 13:43
  • There are many other possible reasons / registry places. See the other answers, and my answer trying a summary. – kxr Mar 22 '16 at 14:38

This registry key file will do it. Copy and paste to a text file called "restore.reg", and double click it to merge into the registry.

It will clear out any per-user setting you may have accidentlly created for .bat files, and restore the system defaults, including the .bat <-> batfile file type relationship as well as the actual parameters for launching a batfile.

Windows Registry Editor Version 5.00



@="\"%1\" %*"
  • also had to run for cmd files on my machine – mohlsen Jan 7 '11 at 18:17
  • 1
    I used this one, at is seemed to work fine. – Håkon K. Olafsen Mar 9 '12 at 8:17
  • After doing this, while double clicking bat file, I am getting error like "a.bat is not a valid win32 application" – rashok Nov 26 '15 at 1:45
  • Works perfectly but to take affect I had to kill explorer.exe and run as a new task again using Task Manager. – Dave Anderson Jul 21 '16 at 23:04
  • This one solved if for me, the selected answer didn't It was still asking for an app to open .bat files. – JDuarteDJ Apr 21 '17 at 10:26

I had the same problem (in Windows 7); batch files were opening in Notepad instead of being executed.

Correcting the below registry for .bat files (as per any other machine where it works) will make the batch execute correctly:


.bat                --> default-> Value not set
.bat/OpenWithList   --> default-> Value not set
.bat/OpenWithProgIds--> default-> Value not set
                        batfile-> Zero length binary values 

Keep these entries but remove all others under .bat. Refresh and run a batch file by double clicking - it will run correctly.


None of the answers above fixed it for the machine I was working with, but what fixed it was starting an Admin Shell and running

assoc .bat=batfile
assoc .cmd=batfile
  • 1
    This is the solution for Win 2008 Server, cmd run as Administrator. No restart of Explorer.exe or Windows required. – TonyG Jul 6 '18 at 3:00
  • Do not work????????????????? – YumYumYum Jan 17 '19 at 11:45
  • 3
    This worked for me on Windows 10 – htxryan Mar 18 '19 at 20:53
  • nope, didn't work on Windows Server 2012 – Toolkit Jun 2 '19 at 6:35
  • 1
    +1. This should be the accepted answer. This is super fast, way safer than digging through the registry, and works for multiple versions of Windows (incl 10). Just make sure you launch in an Admin Shell, as the answer suggests: launch cmd.exe as administrator. – J.D. Mallen Jan 12 '20 at 0:56

The information in this answer led me to the solution to my question.

I opened the registry key mentioned there and

  • deleted the UserChoice key
  • removed all entries under the OpenWithList key

The answer that got 40 votes by Kaleb didn't work for me but I ended up finding the answer. To get the bat file to execute again, you have to go to:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes.bat] and set (Default) to "batfile". If you have batch scripts opening in Word or Notepad++ instead of running on double click, it's because those programs have set (Default) to their own mimes.

If you want a quick fix, just open a text file and paste:

    Windows Registry Editor Version 5.00


And save it with a .reg extension and double click to merge.


In the regisrty you .bat entry needs to point to the batfile entry:


Naturally you will also need to make sure you have a batfile registry entry:

@="MS-DOS Batch File"

In Windows 8 use Notepad to make or modify a Batch file but the secret is the following:

Save the batch file using double quotes. Literally use "MYBACK.BAT" using the double quotes in the save box to save the file. Instead of MYBACK.BAT

  • True (same for previous versions of Windows/Notepad). But how does that answer the question? – Arjan Jul 29 '14 at 20:13

The registry contents vary for different Windows versions.

I suggest that you find another computer with the same O/S version, and use regedit to export the contents of HKEY_CLASSES_ROOT\.bat and HKEY_CLASSES_ROOT\batfile.

Then go to the Boss's machine, delete the above two keys and import the two files.


To avoid the hassle (and for many people scariness and intimidation) of editing the registry, you could use the free, excellent, and non-invasive repair utility which actually accomplishes any good (versus many other crapware), tweaking.com Windows Repair.

Specifically: install it, skip ahead to the "Repairs" tab, click "Open Repairs," and put a checkmark in "04 Register System Files," then click the "Start Repairs" button.

The user interface of that program has changed over time, so in the future, anyone doing this may need to explore the program to find this option.

I would hazard a guess that a lot of other problems exist on your Boss' computer, so that he may want to run all the program's repairs, which can take hours, depending.

Note: I am not affiliated with tweaking.com; I'm just a big fan of the program. Skilled use of it has saved my computer's operating system or solved stubborn problems multiple times.


Again, none of the previous answers did it here.
I for example had to change the default value of [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\batfile\shell] from edit to open.

(Once I had changed the file type extend associations in Explorer folder options dialog. BAT files were & are not offered for change. There seems to be a special exception. But I remember, once I added the BAT type in the Explorer folder options dialog, to get 'edit' being the default shell verb.)

Various places to inspect

So after all there are varying reasons and varying OS version, and (at least) the (default) values of the following registry folders (and subfolders) need to be checked - using some common sense :-). And I think that list may reflect the order of precedence which is relevant to the OS:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat]  (if present: remove "UserChoice")
[HKEY_CURRENT_USER\Software\Classes\.bat]  (if present: @ = "batfile")
[HKEY_CURRENT_USER\SOFTWARE\Classes\batfile]  (if present)
[HKEY_CURRENT_USER\SOFTWARE\Classes\batfile\shell]  (if present: @ = "open")
[HKEY_CURRENT_USER\SOFTWARE\Classes\batfile\shell\open\command]  (if present: @ = "\"%1\" %*")
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.bat]  @ = "batfile"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\batfile\shell]  @ = "open"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\batfile\shell\open\command]  @ = "\"%1\" %*"
[HKEY_CLASSES_ROOT\.bat]  @ = "batfile"
[HKEY_CLASSES_ROOT\batfile\shell]  @ = "open"
[HKEY_CLASSES_ROOT\batfile\shell\open\command]  @ = "\"%1\" %*"

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