Can't execute batch file without extension

  • Thread starter Thread starter zhongsheng
  • Start date Start date
Z

zhongsheng

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
 
zhongsheng said:
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

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}
 
Thanks for the reply,

It says:

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


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

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

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

Thanks,

zhongsheng
 
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?
 
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
 
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
 
Back
Top