Can't execute batch file without extension

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
 
P

Pegasus \(MVP\)

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}
 
Z

zhongsheng

Thanks for the reply,

It says:

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


zhongsheng
 
P

Pegasus \(MVP\)

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

zhongsheng

Here it is:

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

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

Thanks,

zhongsheng
 
P

Pegasus \(MVP\)

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?
 
Z

zhongsheng

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
 
P

Pegasus \(MVP\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top