命令提示符执行同名文件的顺序(a.bat vs a.cmd vs a.exe) [英] Order in which command prompt executes files with the same name (a.bat vs a.cmd vs a.exe)

查看:30
本文介绍了命令提示符执行同名文件的顺序(a.bat vs a.cmd vs a.exe)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows 命令提示符执行名称相同但扩展名不同的文件的顺序是什么?

What is the order in which the Windows command prompt executes files with the same name, but different extensions?

例如,我有一堆可执行文件:something.cmdsomething.batsomething.exe.当我在命令提示符中输入 something 时(假设它们在路径上等),哪些会被执行?如果那个文件不存在,那么会执行哪个?

For example, I have a bunch of executable files: something.cmd, something.bat and something.exe. Which of these would be executed when I typed something into a command prompt (given they were on the path, etc.)? If that file did not exist which one would then be executed?

有没有描述这个的参考资料?

Is there a reference that describes this?

推荐答案

好的,我根据我进行的其他一些搜索做了一些快速实验.

Okay, I did some quick experimentation based on some other searches I had going.

要点是命令的顺序取决于扩展存储在 PATHEXT 环境变量中的顺序.所以最初我有:

The gist is that the order of the commands is dependent on the order the extensions are stored in the PATHEXT environment variable. So initially I had:

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.RB;.RBW

对于上面的例子,它运行的顺序是:

and for the example above the order in which it would run it was:

something.exe
something.bat
something.cmd

改变它们在 PATHEXT 环境变量中定义的顺序确实改变了它们的执行顺序.

Changing the order which they were defined in the PATHEXT environment variable did indeed change the order in which they were executed.

这篇关于命令提示符执行同名文件的顺序(a.bat vs a.cmd vs a.exe)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆