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
- 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.
- Unzip the archive and run the enclosed registry file
- Click Yes when you’re asked for a confirmation to continue
- 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.
- Start the Registry Editor (
- Go to the following key:
- Set the
(default)value data to
- Go to the following key:
- 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
- Then, proceed to the following key:
(default)and set its value data to:
- Go to the following branch:
The values present under one of its subkeys (
UserChoice) may be causing the problem.
- Right-click on the
.batkey, and choose
Yeswhen 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
.batfile association defaults.
- 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.
- Open Notepad or your favorite text editor.
- Copy the following lines and paste it into Notepad
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.bat] @="batfile" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\batfile\shell] @=- [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\batfile\shell\open\command] @="\"%1\" %*" [-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat]
- Save the file with any name having the
fix_bat.regto 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.
About the author
Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and has a vast experience in Windows — delivering support for Microsoft's consumer products. He has been a Microsoft MVP (2003-2012) who contributes to various Windows support forums.