windows - To associate file extension with specific program
问题描述
I'm trying to associate specific file extensions with specific programs. For example, when I press Enter on .txt
file, it should be opened in Sublime Text. Or may be in Vim. Or may be in Chrome.
I need to achieve it with command line. At first glance, it could be achieved in the following way:
FTYPE txtfile=C:\Program Files\Google\Chrome\Application\chrome.exe "%1"
ASSOC .txt=txtfile
But actually it does nothing for me: .txt
files opens in Sublime Text, not in browser.
What I'm doing wrong?
解决方案
I would expect the following to function as intended, despite my reluctance to advise it.
@"%__AppDir__%reg.exe" Add "HKCU\Software\Classes\.txt" /VE /D "txtfile" /F > NUL
@"%__AppDir__%reg.exe" Add "HKCU\Software\Classes\txtfile" /VE /D "Text Document" /F > NUL
@"%__AppDir__%reg.exe" Add "HKCU\Software\Classes\txtfile\shell\open\command" /VE /D "\"%ProgramFiles%\Google\Chrome\Application\chrome.exe\" \"%%L\"" /F > NUL
"%__AppDir__%reg.exe" Add "HKCU\Software\Classes\.txt" /VE /D "txtfile" /F > NUL
"%__AppDir__%reg.exe" Add "HKCU\Software\Classes\txtfile" /VE /D "Text Document" /F > NUL
"%__AppDir__%reg.exe" Add "HKCU\Software\Classes\txtfile\shell\open\command" /VE /D "\"%ProgramFiles%\Google\Chrome\Application\chrome.exe\" \"%L\"" /F > NUL
推荐阅读
- c# - 具有 DeserializeObject 的动态类提供错误:找不到用于类型的默认构造函数
- mysql - 通过 MongoDB BI 连接器连接到 Tableau 时出错
- node.js - 如何在 vs-code 中调试安装在 bot (botpress) 中的 botpress 模块?
- android - 尝试在空对象引用上调用虚拟方法“boolean android.media.AudioManager.isBluetoothA2dpOn()”
- jquery - 如何在点击时隐藏手风琴
- pact - 在提供者服务中,我们可以有两个或多个具有相同状态或提供者状态的交互吗?
- reactjs - 如何使用 react 和 typescript 解决程序化导航问题
- r - 分层数据聚合和操作
- android - 获取 java.lang.SecurityException:DownloadManager:用户 10173 和当前进程都没有 android.permission.ACCESS_ALL_DOWNLOADS
- list - 如何在 q# 中选择列表的唯一元素?