从命令行获取 Windows 10 中文件类型关联的最佳方法? [英] Best way to get file type association in Windows 10 from command line?

查看:17
本文介绍了从命令行获取 Windows 10 中文件类型关联的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以在命令行上使用 assoc 和 ftype 来获取文件类型关联.所以当我这样做时:

I am aware that I can use assoc and ftype on the command line to get the file type assocation. So when i do:

我的印象是 .html 文件是用 iexplorer 打开的.

I am under the impression that .html files are opened with iexplorer.

但是 html 文件是用 chrome 打开的,因为 chrome 已被设置为 html 文件的默认应用程序.

However html files are opening with chrome since chrome has been set as the default app for html files.

当程序确实以 chrome 打开时,为什么 ftype 会给我 iexplorer?

Why is ftype giving me iexplorer when indeed the program opens with chrome?

推荐答案

看来 ftype 和 assoc 在运行 Windows 8 或更高版本的系统上相当无用.

It seems that ftype and assoc are pretty useless on systems running Windows 8 or later.

这是因为 Microsoft 在 Windows 8 中决定用户只能通过内置 GUI 设置默认程序.这可能是由于安全原因和应用程序劫持文件类型关联的问题.

This is due to the fact that Microsoft decided in Windows 8 that users should be able to set default programs only via the built in GUI. This probably was due to security reasons and trouble with applications hijacking file type associations.

因此引入了一个新的注册表项,Windows 现在将用户选择写入

Therefore a new registry key was introduced and Windows now writes the user choice to

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts<extension>UserChoice

密钥包含一个 Prog-Id 和一个哈希值.正确的 Hash 值证明 UserChoice ProgId 值是由用户设置的,而不是由任何其他应用程序设置的.如果哈希无效,windows 会将用户选择重置为默认应用程序.

The key contains a Prog-Id and a Hash Value. The correct Hash value proves that the UserChoice ProgId value was set by the user, and not by any other application. If the hash is invalid, windows will reset the user choice to the default application.

ftype 命令 但是不知道上述注册表项.

The ftype command however is not aware of the above registry key.

它读取 HKCRhtmlfileshellopencommand(Default) 注册表项并打印出结果.

It reads the HKCRhtmlfileshellopencommand(Default) registry key and prints out the result.

因此,ftype 命令的结果无法用于确定哪个应用程序与特定文件扩展名相关联.

Therefore the results of the ftype command therefore are not usuable to determine which application is associated with a specific file extension.

这篇关于从命令行获取 Windows 10 中文件类型关联的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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