Tech Support > Microsoft Windows > Can't execute batch file without extension
Can't execute batch file without extension
Posted by zhongsheng on February 20th, 2008


Hi,

I have this batch command problem and don't know how to resolve it.

For example, I have a batch file called mytest.bat.

It works if I double click it in Windows Explorer
It works if I type mytest.bat in DOS Window
It does not work if I just type mytest.

I can't find any reference to this problem. I hope somebody can point me out
on this. This prevents me from doing lots of stuff.

Thanks,

zhongsheng

Posted by Pegasus \(MVP\) on February 20th, 2008



"zhongsheng" <zhongsheng@discussions.microsoft.com> wrote in message
news:22BF74EC-B90D-47C4-9B91-1B409B957FE9@microsoft.com...
What do you see when you do this:
1. Create the file c:\MyTest.bat
2. Put this line inside:
echo Hello world.
3. Open a Command Prompt (Click Start / Run / cmd {OK}
4. Type this command:
c:\MyTest {Enter}



Posted by zhongsheng on February 20th, 2008


Thanks for the reply,

It says:

C:\>mytest
'mytest' is not recognized as an internal or external command,
operable program or batch file.


zhongsheng

"Pegasus (MVP)" wrote:

Posted by Pegasus \(MVP\) on February 20th, 2008


OK. Now what to you see when you open a Command Prompt
and type these commands:
set pathext{Enter}
assoc .bat{Enter}


"zhongsheng" <zhongsheng@discussions.microsoft.com> wrote in message
news:E1B62D12-C4EF-47F9-92ED-DEBD6AEEF03E@microsoft.com...


Posted by zhongsheng on February 20th, 2008


Here it is:

C:\>set pathext
PATHEXT=.com;.exe;.cmd;.vbs;.js;.jse;.wsf;.wsh;.pl ;.pls

C:\>assoc .bat
..bat=batfile

Thanks,

zhongsheng

"Pegasus (MVP)" wrote:

Posted by Pegasus \(MVP\) on February 20th, 2008


Your %pathext% lacks the .bat component. You need to restore it here,
then reboot the machine:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

You can test this immediately by renaming your batch file to
MyTest.cmd. Does this work?


"zhongsheng" <zhongsheng@discussions.microsoft.com> wrote in message
news:F8845F5B-8ADC-4C9E-AB0D-00A2D898C17F@microsoft.com...


Posted by zhongsheng on February 20th, 2008


Thank you very much.

I changed that from environment variable table. It works now. I am wondering
how has that happened. I don't believe I have ever touched pathext before
from neither environment variable nor regedit.

zhongsheng

"Pegasus (MVP)" wrote:

Posted by Pegasus \(MVP\) on February 20th, 2008


Congratulations!
By thinking of the time when it happened, you can probably
work out "who dunnit", e.g.
- Some software installation
- Malware
- Virus infection
- Someone else playing with your machine
- You playing with your machine


"zhongsheng" <zhongsheng@discussions.microsoft.com> wrote in message
news:2B6992C8-CDAF-4B4C-9387-F9590FAD0696@microsoft.com...



Similar Posts