[Fix] Windows Batch Files (.bat) do not run when double-clicked

When you double-click a Windows batch file (.bat), one of the following symptoms may happen:

  • The batch file opens a Command Prompt window but its commands doesn’t execute.
  • Notepad or any other text editor opens (edit) the batch file contents.

This post tells you how to fix .bat file association so that Windows runs batch files correctly.

[Fix] .BAT files do not run when double-clicked

Windows Batch file (.bat) is a special file type using which you can run or automate a series of commands. The Command Prompt reads and interprets the batch file, and runs each command specified in the file.

It’s possible that the user has inadvertently associated .bat files with a text editor, or associated .bat files with cmd.exe, or tampered with the settings in the registry. Once you set a file association for .bat files using the Open with dialog or default programs, there is no way to revert to the default setting using the user interface. The only way to fix it is by changing the settings in the registry.

Follow these steps to fix the Windows Batch file association:

Method 1: Use .BAT file association registry fix

  1. Visit the Windows 10 file association fixes page, download the .bat file association fix. If you’re using an older Operating System such as Windows 7 or Windows 8, you can find the links to the fixes for those Operating Systems down below on that page.
  2. Unzip the archive and run the enclosed registry file
  3. Click Yes when you’re asked for a confirmation to continue
  4. Click OK.

Method 2: Fix the .BAT file association manually

Important: Before proceeding, create a System Restore point as a safety measure. Incorrect modification of the Windows registry can cause serious problems.

  1. Start the Registry Editor (regedit.exe)
  2. Go to the following key:
  3. Set the (default) value data to batfile
  4. Go to the following key:
  5. In the right-pane, make sure that the (default) value data is not set. It should read as value not set. In case you see some other text there, then right-click the (default) value and choose Delete.
  6. Then, proceed to the following key:
  7. Double-click (default) and set its value data to:
    "%1" %*
  8. Go to the following branch:

    The values present under one of its subkeys (OpenWithList, OpenWithProgids and UserChoice) may be causing the problem.

  9. Right-click on the .bat key, and choose Delete. Click Yes when prompted for confirmation. Don’t worry! This registry key and its three subkeys are trivial, and they’re only required if you want to override the .bat file association defaults.
  10. Exit the Registry Editor.

Method 3: Make your own REG file to automate the steps listed in Method 2

If you want to automate the steps listed in Method 2, use this method. The difference between Method 1 and Method 3 is that in Method 1, every detail of the .bat file type registration is taken care of. Whereas Method 2 is somewhat surgical — that is, it checks for and removes overridden entries only.

  1. Open Notepad or your favorite text editor.
  2. Copy the following lines and paste it into Notepad
    Windows Registry Editor Version 5.00
    @="\"%1\" %*"
  3. Save the file with any name having the .reg extension, say fix_bat.reg
  4. Double-click fix_bat.reg to apply the configuration in the registry. Click Yes when prompted for confirmation.

That’s it! You’ve now fixed the batch file association settings. Batch files should now execute correctly when double-clicked.

One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

24 thoughts on “[Fix] Windows Batch Files (.bat) do not run when double-clicked”

  1. thanks for the information.

    i got rid of the problem through the reset this pc icon
    i bet your solution would work if i followed your method.

  2. I followed your manual registry method. All the keys were already correct, so all I did was delete the .bat key as instructed. It had no effect. *.bat files still don’t execute in Win10. The just open in notepad.

  3. Hi
    I have another Question
    I open a bat file with notepad and now all of my bat file open with note pad How I can make my bat file RUN on my windows???
    I use windows 7

  4. I tried all the methods, still my windows batch file doesn’t open. The command prompt either flashes and goes off or nothing happens when I try to open the file. Can you help please?
    I was able to open the file before a few weeks

    • @Viswes: That means the .bat file association is not the issue here. Adding the Pause command in between your batch file code would tell what’s happening when the file runs.

  5. It’s a file downloaded from the internet and it runs correctly for others,
    is there any other thing I can do open the file. Thank you so much for your help.

  6. I tried to follow the steps, but they are not working. Furthermore, now also other software have problems. How can I ripristinate the subkeys (OpenWithList, OpenWithProgids and UserChoice) that I deleted?
    Thank you.


    • @Matteo:

      Here’s the default registry entries for .bat under Fileexts

      Windows Registry Editor Version 5.00

      The UserChoice key doesn’t exist by default.

  7. I tried all of these (including the .[@echo hi / @pause] bat file and bat files still open in a text editor. Anything else I can try?

  8. Well, after trying all of these methods to modify the regedit, it didn’t work. I’m sure I did something wrong. The problem is the system think the bat file is a text file. Simply rename it in explorer, will not work. But if you use the command to rename it back to the *.bat, it will work.
    CMD into the directory where you have the bat file. You will see your bat file has an extension like *.bat.txt. Use the command ren file.bat.txt file.bat. It should rename it back to the correct *.bat file format. Now it works… for me.

  9. I have had this issue for a while and I knew something had changed the ability to run commands and batch files so I eventualy got around to it today.
    I never thought it would be so simple!
    IU merely copied your REG file commands into a txt doc and saved it as fixbat.reg. I ran the file and hey presto, the batchfile I had been trying to run just worked right away!

  10. This article does not help. I don’t have .bat associated with a text editor and the shell window just opens for a split second. Where’s the explanation and workaround for “The batch file opens a Command Prompt window but its commands doesn’t execute.”?

  11. The registry keys are not there.
    HKEY_CLASSES_ROOT\batfile\shell and HKEY_CLASSES_ROOT\batfile\shell\open\command don’t exist.

  12. Hi, I am getting this message while running .bat file it says “Windows cannot find ‘C\Program Files\MPV\mpv-install.bat’. Make sure you have typed the name correctly, and then try again.


Leave a Comment