如何燮preSS“打开方式”窗口 [英] How to suppress 'Open with' window
问题描述
在运行里面有一个未知的扩展名的文件(可以说 test.nope
)的命令行或批处理文件 - 使用测试。都能跟得上
,呼叫test.nope
或启动test.nope
- 你是$ p $有一个窗口psented要求您选择你想用来打开此文件的程序
(在Windows 7中,presumably大多数Windows操作系统的)。
When running a file which has an unknown extension (lets say test.nope
) from the command line or a batch file - using test.nope
, call test.nope
or start test.nope
- you are presented with a window asking you to "Choose the program you want to use to open this file"
(in Windows 7, presumably in most Windows OS's).
是否有可能燮preSS这个窗口?
我最初的想法是,以检查是否在%PATHEXT%
变量存在扩展试图打开文件之前。但是,这不包含的所有的已知文件的扩展。例如,尽管的.py
扩展名是不是在我的%PATHEXT%
变量,Python脚本仍然正确打开。
My initial thought was to check if the extension exists in the %PATHEXT%
variable before attempting to open the file. However, this does not contain all known file extensions. For example, though the .py
extension is not in my %PATHEXT%
variable, Python scripts are still opened correctly.
推荐答案
文件类型在 HKCR \\
注册(的,可以从MSDN 完整的文档)。你可以找出是否一个类型是通过检查密钥是否存在注册。在一个批处理文件,则可以使用章
命令这样做。
File types are registered in HKCR\
(full documentation available from MSDN). You can find out if a type is registered by checking for the existence of the key. In a batch file, you could use the reg
command to do so.
reg query HKCR\.txt || echo This will never print
reg query HKCR\.foobartxt || echo Could not find foobartxt
话虽这么说,文件类型可以被定义和命名,而无需一个默认的处理程序。此外,那些有默认的处理程序可能没有命令行 - 该文件可以通过DDE或COM推出
That being said, file types can be defined and named without having a default handler. Further, those which have default handlers may not have command lines - the file may be launched via DDE or COM.
这篇关于如何燮preSS“打开方式”窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!