如何设置“默认应用"用于".exe"文件扩展名2018年4月更新后在Windows 10上 [英] How do I set "default App" for a file extension to an ".exe" on Windows 10 after April 2018 update

查看:110
本文介绍了如何设置“默认应用"用于".exe"文件扩展名2018年4月更新后在Windows 10上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了很长时间研究这个.大多数解决方案发布于2018年4月之前,涉及通过设置"逐步进入按文件类型选择默认应用"的方法.

I have spent a very long time researching this. Most of the solutions were posted PRIOR to April 2018, and involved working your way through the "settings" to get to "Choose default Apps by file type".

按文件类型选择默认应用

在先前尝试将应用程序分配给".rex"的过程中,我设法将其分配给记事本. (当时,我找不到在C:驱动器上找到".exe"的任何方法.)

In previous attempts to assign an app to ".rex" I managed to assign it to Notepad. (At that time, I could not find any way to find an ".exe" on my C: drive.)

因此,如您所见,如果单击.rex扩展名旁边的记事本,则唯一的选择是转到应用程序商店".

So as you can see, if you click on Notepad next to the .rex extension, the only option is to go to the "App store".

与预期的一样,如果您单击App Store,则找不到任何内容...

And as expected, if you click on App store, nothing is found...

应用商店-未找到任何应​​用.

因此,从我在2018年4月之前在多个论坛上阅读的内容来看,Windows 10仍然可以浏览硬盘"来找到".exe". (就像在旧版Windows中一样.)在2018年4月进行了一些更新之后,该功能不再存在.

So from what I've read in multiple forums, PRIOR to April 2018, Windows 10 still had a way to "browse your hard drive" to find an ".exe". (Just like in older Windows versions.) After some update in April 2018, that capability no longer exists.

在2018年4月的POST中,是否有人找到一种将文件扩展名分配给硬盘驱动器上的".exe"的方法?

In the POST April 2018, has anyone found a way to assign a file extension to an ".exe" on the hard drive???

推荐答案

我认为这个问题更适合 SuperUser (嗯,除非您想通过程序来完成它:)).

I think this question would be more suitable for SuperUser (well, unless you want to do it via a program :) ).

无论如何,这是一种通过控制台( cmd )进行操作的方法.我在1或2年前尝试过,现在才尝试过,因此无论 Win(10)版本如何,它都可以工作.
从头开始该过程:

Anyway, here's a way of doing things from console (cmd). I've tried it 1 or 2 years ago, I just tried it now, so it works regardless of Win (10) version.
Start the process from scratch:

  1. 打开一个命令提示符窗口.创建一个 OS 一无所知的新文件.我选择了扩展名 .zzz :

  1. Open a Command Prompt Window. Create a new file that the OS doesn't know anything about. I chose the extension .zzz:

e:\Work\Dev\StackOverflow\q052008516>ver

Microsoft Windows [Version 10.0.17134.228]

e:\Work\Dev\StackOverflow\q052008516>dir /b

e:\Work\Dev\StackOverflow\q052008516>:: Create a dummy .zzz file
e:\Work\Dev\StackOverflow\q052008516>echo Some dummy text>file.zzz

e:\Work\Dev\StackOverflow\q052008516>dir /b
file.zzz


  1. 尝试从文件浏览器打开文件( DblClick )(无关紧要,但是我使用总指挥官),或在 cmd 中键入其名称.这将产生可怕的对话框:

  1. Try opening the file (DblClick) from a file browser (it's not relevant, but I use Total Commander), or by typing its name in cmd. That will yield the dreaded dialog:


  1. 创建一个新的文件类型并将其扩展名与之关联. [MS.Docs]:assoc 实用程序是用来做这项工作的.首先,检查这种关联是否还不存在:

  1. Create a new file type and associate our extension with it. [MS.Docs]: assoc utility is used to do the job. First, check if such association doesn't already exist:

e:\Work\Dev\StackOverflow\q052008516>:: No output means no association
e:\Work\Dev\StackOverflow\q052008516>assoc | findstr ".zzz"

e:\Work\Dev\StackOverflow\q052008516>:: Same command for a different extension
e:\Work\Dev\StackOverflow\q052008516>assoc | findstr ".txt"
.dic=txtfile
.exc=txtfile
.log=txtfile
.scp=txtfile
.txt=txtfile
.wtx=txtfile

e:\Work\Dev\StackOverflow\q052008516>:: Create a new FileType (ZZZFile) and associate our extension with it
e:\Work\Dev\StackOverflow\q052008516>assoc .zzz=ZZZFile
.zzz=ZZZFile

e:\Work\Dev\StackOverflow\q052008516>assoc | findstr ".zzz"
.zzz=ZZZFile

尝试打开文件时保持不变.

No change when trying to open the file.


  1. 将文件类型(上一步中的 ZZZFile )与命令相关联.使用 [MS.Docs]:ftype 任务工具.再次,检查文件类型是否尚未关联(仅当文件类型在上一步之前存在时才有意义):

  1. Associate the file type (ZZZFile, from previous step) with a command. Use the [MS.Docs]: ftype tool for the task. Again, check if the file type is not already associated (this only makes sense if the file type existed before previous step):

e:\Work\Dev\StackOverflow\q052008516>:: As usual, no output means no association
e:\Work\Dev\StackOverflow\q052008516>ftype | findstr ZZZFile

e:\Work\Dev\StackOverflow\q052008516>:: Same thing for txtfile
e:\Work\Dev\StackOverflow\q052008516>ftype | findstr txtfile
txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1

e:\Work\Dev\StackOverflow\q052008516>:: Associate ZZZFile with notepad
e:\Work\Dev\StackOverflow\q052008516>ftype ZZZFile=%SystemRoot%\system32\notepad.exe %1
ZZZFile=C:\WINDOWS\system32\notepad.exe %1

e:\Work\Dev\StackOverflow\q052008516>ftype | findstr ZZZFile
ZZZFile=C:\WINDOWS\system32\notepad.exe %1


  1. 尝试再次打开文件(来自 cmd ),然后打开voilà:


为了使用扩展名为 .zzz notepad.exe 文件打开,只有 2个命令需要从整个答案中记起(很长):

In order to open with notepad.exe files having .zzz extension, there are only 2 commands that need to be remembered from this whole (and pretty long) answer:

  • assoc .zzz=ZZZFile
  • ftype ZZZFile=%SystemRoot%\system32\notepad.exe %1
  • assoc .zzz=ZZZFile
  • ftype ZZZFile=%SystemRoot%\system32\notepad.exe %1

注释:

  • 我的用户具有(超级)个管理权限,但我想根据( cmd UI (如果可能)),换句话说,没有所需特权的用户将无法执行此操作,无论他们会尝试什么
  • 很明显,这个问题上有一个(很暗)星云,我的知识还无法破译".在我的示例中,我不断将 .zzz 的结果与 .txt 进行比较.然而,一个大惊喜: Notepad ++ not Notepad 用于打开 txtfile (尽管有上述输出)(仅 .txt )
  • My user has (super) administrative privileges, but I guess they shouldn't impact differently depending where the action is performed from (cmd or UI (if possible)), in other words users that don't have the required privileges, won't be able to do it, no matter what they would try
  • Apparently, there is a (pretty dark) nebula on this topic, that my knowledge wasn't yet able to "decipher". In my example, I constantly compare the .zzz results to .txt. Yet a big surprise: Notepad++ and not Notepad is used to open txtfile (.txt only), in spite of the above output

@ EDIT0 :

@EDIT0:

我进一步挖掘了 .txt 的奥秘.事实:

I did a little more digging on the .txt mystery. Facts:

  • ftype 记事本显示为打开程序
  • 它实际上是由 Notepad ++ 打开的(在 cmd PS 中)
  • 按文件类型选择默认应用中,显示 Notepad ++
  • ftype shows Notepad as opening program
  • It is actually opened by Notepad++ (in cmd and PS)
  • In Choose default apps by file type, Notepad++ is shown

因此,显然,它不只是让人眼前一亮(这些年来,我习惯了 MS 的做事方式,在某些情况下似乎是这样(但也许是我自己做过的事)没有所有的碎片)ilogic). 我还发现了很多资源,例如:

So apparently, it's more than meets the eye (over the years, I got used to MS's way of doing things which in some cases seems to be (but maybe it's me who didn't have all the pieces) ilogic). I've also found out many resources like:

  • [MS.Technet.Blogs]: Windows 10 – How to configure file associations for IT Pros? which mentions the command:
dism /online /export-defaultappassociations:"file.txt"

  • [XDADevelopers]:以编程方式设置默认文件关联其中提到了 reg 键:
    • HKCU \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ FileExts \ $ {EXT}
    • HKCR \ $ {EXT}
    • [XDADevelopers]: Programatically set default file associations which mentions the reg keys:
      • HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${EXT}
      • HKCR\${EXT}
      • 在任何地方我都找不到一个清晰的算法来确定如何选择一个可执行文件来运行具有特定扩展名的文件.我可以认为上面的2个键已被查询,但我 100%肯定还有更多.更不用说对于 .py 文件,我遇到了一个甚至更陌生的问题(对于我的 Win 10 的普通用户):

        I couldn't find anywhere a clear algorithm of how an executable is chosen to run a file with a certain extension. I can think that the 2 keys above are queried, but I'm 100% sure there's more. Not to mention that I've ran into an even stranger problem (for a regular user on my Win 10), for .py files:

        • ftype (和 assoc )报告了上述所有内容
        • 按文件类型选择默认应用中,显示了 Python (就像在我的 Super Admin 用户案例中一样)
        • 尝试从 cmd 运行文件,在开始时显示对话框
        • 它来自 PS
        • ftype (and assoc) reported everything as above
        • In Choose default apps by file type, Python was shown (just like in my Super Admin user's case)
        • Attempting to run the file from cmd, yielded the dialog at the beginning
        • It worked from PS

        可悲的是,在查看 reg 键之前,我从对话框中选择了 Python (现在它可以工作了),因此我无法再进行调试了(而且,切换用户很烦人.)

        Sadly, I selected Python from the dialog, before taking a look at the reg keys (and now it works), so I can't do any more debugging (and also, switching users is annoying).

        可能相关:

        • [SuperUser]: Windows 10 won't let me set default apps for file extensions
        • [SuperUser]: Can't change Windows 10 default file type association
        • [SuperUser]: SSMS wont give up file associations

        这篇关于如何设置“默认应用"用于".exe"文件扩展名2018年4月更新后在Windows 10上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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