Running Windows 8.1. This worked a few days ago. Really do not know what has changed, nor am I aware of any update that might have stopped this working.
When I run a .bat (batch) file (right-click > Open
or double-click
) the batch file is displayed in Notepad++ and does NOT run. If I load a command prompt and manually run the .bat file from inside the command prompt, the batch file runs perfectly.
I've carefully checked these two articles:
How do I restore .bat files association with the system (make them run when double-clicked)? https://stackoverflow.com/questions/4905708
and nothing makes a difference. Specifically:
From a command prompt:
assoc .bat
returns.bat=batfile
ftype batfile
returnsbatfile="%1" %*
After everything I've tried, the PC has been rebooted with no difference. This is driving me crazy...why won't batch files run any more?
assoc .cmd
? Useassoc .cmd=batfile
if required (in an elevated CMD)..bat
file to.cmd
and it worked! From the command line I typedassoc .cmd
and.cdm=cmdfile
was returned. Am now in the process and work out what the differences are betweenHKEY_CLASSES_ROOT\batfile
andHKEY_CLASSES_ROOT\cmdfile
. Weird thought, but will all my batch files work if rename them from.bat
to.cmd
?.bat
files. Am curious why Microsoft even have aHide file extensions
option. Why would it be sensible to allow the user to accidentally runDoSomething.txt.exe
? Its just a recipe for accidental errors or security risks. Should never be an option - the full filename with extension should be displayed.