my.bat not recognized as an internal or external command, operable program or batch file
Solution 1
My stupid mistake...
Credit should go to Dennis for verifying that my.bat should work but as he surmised, it was not named that. I thought I had renamed it correctly from my.txt to my.bat but the problem was that it was actually named my.bat.txt ! Fixing that was key to this problem.
Solution 2
I was getting this error because my batch file was not ascii encoded; it was utf-8.
Since UTF and UCS often contain a BOM at the start of the file, make sure to save it as ASCII or UTF-8 without the BOM.
If you really need an alternate encoding, making the first line blank can sometimes work (for me the UTF-8 BOM doesn't stop execution, but the USC-2 one does). Both will print an error message from the first line, so it's not an ideal solution.
John Adams
Updated on April 29, 2020Comments
-
John Adams almost 4 years
When I logon to this Windows 2008 R2 Server and launch a CMD window, the default directory is:
C:\Users\SVC_asl2trim>
So I added this to the PATH and then I issued:
C:\Users\SVC_asl2trim>set path Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32 \WindowsPowerShell\v1.0\;D:\Program Files\Hewlett-Packard\HP TRIM\;C:\Users\SVC_ asl2trim\ PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC C:\Users\SVC_asl2trim>
I have a small .bat file in that directory above but I keep getting:
my.bat not recognized as an internal or external command, operable program or batch file
This is maddening. I do this so infrequently .... I know there is some trick I am forgetting.
-
heltonbiker almost 11 yearsActually most of the question body is unrelated to the actual problem, and mostly distracting. Anyway, your answer solved my problem :)
-
Thom Ives over 3 yearsA production server had extensions turned off, and that resulted in notepad doing to me what happened to you - this answer saved me time!