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?

link|improve this question

76% accept rate
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
umm...i'm guessing that's why he's da boss? ;) – justSteve Oct 9 '09 at 1:12
2  
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
feedback

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

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

5 Answers

up vote 7 down vote accepted

I think you'll have to remove the .bat file association from the registry (using the regedit program). According to this page, in XP the registry setting you need to remove is the ones UNDERNEAT of HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat, and in Vista it is HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat.

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

link|improve this answer
feedback

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\" %*"
link|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 at 8:17
feedback

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.

link|improve this answer
feedback

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"
.....
link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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