none
Lost .bat file association

    Question

  • I have made the unfortunate mistake of associating .bat file extension to a notepad utility. This is no good as batch files do not run as they should but open up in the notpead utiltiy to be edited. How can i reassociated the .bat file extension to the appropriate windows function to get it to run as it should?
    Monday, September 07, 2009 11:38 PM

Answers





  • You must take ownership of this restricted registry key. Open regedit and navigate to the key you see here.



    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\UserChoice
    ----------------------------------------------------------------------------------------------------------------------



    Delete the key named "user choice" and the association with note pad will end restoring it to it's original state.






    • Proposed as answer by Brian Borg Tuesday, September 08, 2009 12:30 AM
    • Marked as answer by Robinson Zhang Tuesday, September 15, 2009 1:58 AM
    Tuesday, September 08, 2009 12:24 AM

All replies

  • There is no option with batch files to change the default opener from the file itself so how and where did you change the default program in the first place? I'm guessing you went to program access and defaults in control panel where the default program is listed as unknown.

    Monday, September 07, 2009 11:51 PM
  • Try the following, as a .reg file:

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\.bat]
    @="batfile"
    
    [HKEY_CLASSES_ROOT\.bat\PersistentHandler]
    @="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
    
    [HKEY_CLASSES_ROOT\batfile\shell\open\command]
    @="\"%1\" %*"
    Tuesday, September 08, 2009 12:14 AM




  • You must take ownership of this restricted registry key. Open regedit and navigate to the key you see here.



    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\UserChoice
    ----------------------------------------------------------------------------------------------------------------------



    Delete the key named "user choice" and the association with note pad will end restoring it to it's original state.






    • Proposed as answer by Brian Borg Tuesday, September 08, 2009 12:30 AM
    • Marked as answer by Robinson Zhang Tuesday, September 15, 2009 1:58 AM
    Tuesday, September 08, 2009 12:24 AM
  • Changing the reg entry:

    Hkey_Local_Machine\Software\Classes\Regfile\Command\Open

    from regedit.exe to notepad.exe looks like a good option hehehe (just a lil parenteses)

    PS: dont remember if thats the exact path but looks like that,it just came out off the top of my head...

    All my best,
    RR
    Tuesday, September 08, 2009 1:49 AM
  • Windows 7 does not have the option to disasociate file types that can be assigned a program only from the control panel and not from the file itself. When you associate this type of file it creates this protected key:

    "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\UserChoice"
     
    and for some reason there is no option from the user interface even in the control panel to remove this key in the form of a selectable button that would say something similar to "disasociate all programs from this file type", no - instead it must be done manually through the registry editor.

    I can not remember if this was the case for windows xp.
    • Proposed as answer by Da_Boom Saturday, September 15, 2012 11:19 AM
    Tuesday, September 08, 2009 4:34 AM
  • Changing the reg entry:

    Hkey_Local_Machine\Software\Classes\Regfile\Command\Open

    from regedit.exe to notepad.exe looks like a good option hehehe (just a lil parenteses)

    PS: dont remember if thats the exact path but looks like that,it just came out off the top of my head...

    All my best,
    RR

    We appreciate the humer but please be carfull that it is not misconstrued as an actual suggestion and my apologies if this is a real suggestion.

    Thanks again, Mate!
    Tuesday, September 08, 2009 5:42 AM
  • Hi HorsHack,
    I need a translator plix pl0x lol
    got 70 % of what you said!
    w8 a minute lemme google it and brb..

    Humer(tot it was written Humor nevermind),misconstrued(got it after google it lol)

    Ok that is actually a real suggestion ,i was not playing with it ,changing that it basically changes the Merge behaviour of windows registry...
    so after altering that entry when you click on .reg files they open in text mode and wont merge it,this is a security measure to avoid registry silent installations(of course u can even via GPO prevent any registry tools from opening),so if you want to merge some entries,all u need to do is switch back to regedit.exe and afterwards get back to notepad.exe just to keep u safer....
    so i was not playing when i suggested that ^^
    NOTE: changing that wont prevent registry from opening,just prevents .reg files from merging,to prevent windows registry from runnning just do it via Group policy object and then when u want to open windows registry just turn it off ,make the desired changes then enable the prevention again ^^

    i think those are some reasonable advices so if you guys want to take it feel free !!!
    All my best,
    RR
    Tuesday, September 08, 2009 6:16 PM
  • Changing the reg entry:

    Hkey_Local_Machine\Software\Classes\Regfile\Command\Open

    from regedit.exe to notepad.exe looks like a good option hehehe (just a lil parenteses)

    PS: dont remember if thats the exact path but looks like that,it just came out off the top of my head...

    All my best,
    RR

    Lol.  Yeah I did that once, only I changed it to Wordpad.
    Tuesday, September 08, 2009 6:58 PM
  • Hehe :D
    aint that nice?
    i have to admit i love changing the registry,of course not in a reckless way(did i spell it right?)
    Regards,
    RR
    Tuesday, September 08, 2009 7:25 PM
  • What if that registry entry doesn't exist?

    http://social.technet.microsoft.com/Forums/en/w7itprogeneral/thread/4ec88c12-164a-4fee-bd82-c33c5fc95434

    Saturday, February 11, 2012 6:09 PM




  • You must take ownership of this restricted registry key. Open regedit and navigate to the key you see here.



    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\UserChoice
    ----------------------------------------------------------------------------------------------------------------------



    Delete the key named "user choice" and the association with note pad will end restoring it to it's original state.






    This worked and was the easiest fix for the problem.  The batch files run now.   I still have to correct the icon picture, but that is only a cosmetic problem.  Thanks.
    Friday, February 17, 2012 6:45 PM
  • Thanks, this worked perfectly and quickly!
    Thursday, June 21, 2012 7:47 PM
  • Right click, select "Open With", then select notepad or notepad++ and this happens. Not hard to see this happening often.
    Thursday, June 21, 2012 7:48 PM
  • Thank you thank you thank you!

    This was driving me nuts, your tip was a lifesaver and fixed the problem instantly.

    Wednesday, October 03, 2012 11:17 PM
  • This worked for me! 

    I had my .bat files associated with a text editor by accident.  Wasn't able to run programs that called .bat files.  Instead of running that would open the file for editing!

    Went into regedit and deleted this key and everything went back to normal.

    Thanks!

    Michael

    Friday, November 02, 2012 3:58 PM
  • I had the same issue on my Windows 8 (x64bit) desktop where .bat files were opening my text editor.
    I tried all the fixes I could find on the internet but no luck. I was finally able to diagnose the problem by associating .bat files with a unique exe like "rumplestiltskin123.exe". Then I searched registry for all occurrences of "rumplestiltskin123"
    It turns out I needed to remove the following roaming registry key also :-

    [-HKEY_CURRENT_USER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.bat\UserChoice

    This fixed the problem for me.


    Saturday, June 22, 2013 10:31 PM
  • Don't ask microsoft, they have no idea about their own system.
    Wednesday, November 13, 2013 8:03 PM