如何设置“默认应用程序"?用于“.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

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

问题描述

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


  1. 创建一个新的文件类型并将我们的扩展名与其关联.


总结:

为了notepad.exe打开具有.zzz扩展名的文件只有2个命令需要从整个(而且很长)的答案中记住这一点:

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

注意事项:

  • 我的用户拥有(超级)管理权限,但我想他们不应该根据执行操作的位置(cmdUI(如果可能)),换句话说,没有所需权限的用户将无法执行此操作,无论他们尝试什么
  • 显然,关于这个主题有一个(相当暗的)星云,我的知识还不能破译".在我的示例中,我经常将 .zzz 结果与 .txt 进行比较.还有一个大惊喜:Notepad++not Notepad 用于打开 txtfile(仅.txt),尽管有上述输出

@EDIT0:

我对 .txt 之谜进行了更多的挖掘.事实:

  • ftype 显示 Notepad 作为打开程序
  • 它实际上是由Notepad++打开的(在cmdPS中)
  • 按文件类型选择默认应用中,显示了Notepad++

显然,这不仅仅是表面上的(多年来,我已经习惯了 MS 的做事方式,在某些情况下似乎是这样(但也许是我没有)没有所有的部分)ilogic).我还发现了许多资源,例如:

我在任何地方都找不到关于如何选择可执行文件来运行具有特定扩展名的文件的清晰算法.我可以认为上面的 2 个键被查询了,但我100%确定还有更多.更不用说我遇到了一个更奇怪的问题(对于我的 Win 10 上的普通用户),对于 .py 文件:

  • ftype(和assoc)报告如上
  • 按文件类型选择默认应用中,显示了Python(就像在我的超级管理员用户案例中一样)
  • 尝试从 cmd 运行文件,在开始时产生对话框
  • 它从 PS

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

可能是相关的:

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".

Choose default Apps by file type

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.)

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".

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

App store - no app's found.

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.

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

解决方案

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

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. 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. 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. 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. 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. Try opening the file again (from cmd), and voilà:


Summary:

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

Notes:

  • 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:

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

  • 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

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:

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 (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

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).

Might be related:

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

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