Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

What do I set the 'Opens with...' property to in order for them to execute?

share|improve this question

migrated from stackoverflow.com Oct 11 '09 at 17:15

This question came from our site for professional and enthusiast programmers.

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
2  
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
    

7 Answers 7

up vote 26 down vote accepted

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:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat

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

share|improve this answer
7  
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\.b‌​at\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 at 6:10

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

[HKEY_CLASSES_ROOT\.bat]
@="batfile"
.....

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

[HKEY_CLASSES_ROOT\batfile]
@="MS-DOS Batch File"
.....
share|improve this answer

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.

share|improve this answer

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

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat]
[-HKEY_CURRENT_USER\Software\Classes\.bat]
[-HKEY_CURRENT_USER\SOFTWARE\Classes\batfile]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.bat]
@="batfile"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\batfile\shell\open\command]
@="\"%1\" %*"
share|improve this answer
    
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

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:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\

.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.

share|improve this answer

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
share|improve this answer

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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