Friday, January 8, 2016
Bad Default Program for CMD and Bat Files
This week I received a .cmd file from my boss and when I downloaded it to my Windows 7 laptop and tried to double click on it in Windows Explorer, it just opened up in a text editor. I am assuming at some point I must have changed the default program for .cmd files to be the text editor, probably because we typically just use .bat files for that type of action. It turns out if you change the file association for one of the standard "executable" types of files it is a little tricky to get it correct. I initially tried updating the file association in the Default Programs control panel, which didn't work. I then attempted to manually edit the registry to remove the file association as recommended by some sites, which also didn't work. I continued researching the issue and the general consensus was that you had to make several registry edits to get things straightened out, but I am not a huge fan of just randomly running registry edits from random sites on the internet. Eventually I found this page on the Microsoft forums, Can't execute bat or cmd files opens Notepad. It mentioned bat_fix_w7.reg, but it wasn't available on the page, so after a little more searching I found winhelponline's File Association Fixes for Window 7, from here I was able to download a registry editor files that would correct my issue. I quickly read through the file in a text editor and it appeared to be mostly updating the HKEY_CLASSES_ROOT\.cmd and HKEY_CLASSES_ROOT\cmdfile to put in new values for cmd files. It also removed any existing file association for the .cmd extension. With some hesitation I ran the command and I was able to successfully run my .cmd files from Windows Explorer again.