1
如何通过提供文件的名称,无扩展名打开.bat中的任何类型的文件? 我想让Windows决定要使用的应用程序。按名称打开文件,没有扩展名
例如:
%SYSTEMROOT%\ explorer.exe的E:\ SomeFolder \
%SYSTEMROOT%\ explorer.exe的E:\ SomeFolder \ file1的
如何通过提供文件的名称,无扩展名打开.bat中的任何类型的文件? 我想让Windows决定要使用的应用程序。按名称打开文件,没有扩展名
例如:
%SYSTEMROOT%\ explorer.exe的E:\ SomeFolder \
%SYSTEMROOT%\ explorer.exe的E:\ SomeFolder \ file1的
使用开始命令:
start "Any title" E:\SomeFolder\
start "Any title" E:\SomeFolder\file1
从开始帮助摘自:
If Command Extensions are enabled, external command invocation
through the command line or the START command changes as follows:
。
non-executable files may be invoked through their file association just
by typing the name of the file as a command. (e.g. WORD.DOC would
launch the application associated with the .DOC file extension).
See the ASSOC and FTYPE commands for how to create these
associations from within a command script.
。
When searching for an executable, if there is no match on any extension,
then looks to see if the name matches a directory name. If it does, the
START command launches the Explorer on that path. If done from the
command line, it is the equivalent to doing a CD /D to that path.
请注意,前面的描述意味着纯文件名还必须执行正确的应用程序,而无需START命令。拿起第一个文件使用相同的名字:
for %%f in (name.*) do set "filename=%%f" & goto continue
:continue
...并执行它:
%filename%
PS - 请注意,你想“让窗口决定使用申请书”,但在您的示例中,您明确选择%SystemRoot%\explorer.exe
作为要使用的应用程序。所以?
这还不清楚。 Windows根据扩展名决定使用哪个程序。另外,扩展名是文件名的一部分,这也是一种惯例。你还问:“我怎样才能打开一个文件没有文件的完整名称”。 – vcsjones
我需要打开excel文件,我不知道天气文件以.xlsx或.xls结尾 – jadrijan
这两个扩展都应该启动Excel。如果其中一个或两个都没有,那可以修复。尝试右键单击Windows资源管理器中的某个“损坏”文件,选择打开方式,从应用程序列表中选择Excel,选中“始终使用此应用程序”复选框,然后单击确定。 – Tom