关于快速关联默认程序

scoop用户或者绿色软件用户可能会遇到,需要设置不少的默认程序

相关的话题不多

简单说,windows启用了新的默认程序管理方式,更加复杂。可参考下文。

SetUserFTA: UserChoice Hash defeated – Set File Type Associations per User or Group on Windows 8/10 and 2012/2016/2019 – the kolbicz blog

再简单说,找到了一个工具,参考下文,预编译程序也在文中。

Set File Type Association Default Application Command Line Windows 10 UserChoice Hash Internal Method - Danysys

就是SFTA

为了方便管理,建议加入自已的scoop bucket。

使用ahk来自动化。

新建一个var.ahk,保存变量。

TextEditor(){
    return "D:\SCOOP\apps\notepadplusplus\current\notepad++.exe"
}

TextFileExtension(){
    return [".txt", ".conf", ".yml", ".xml", ".log", ".json"]
}

ImageViewer(){
    return "D:\SCOOP\apps\irfanview\current\i_view64.exe"
}

ImageFileExtension(){
    return [".png", ".jpg", ".gif"]
}

BookReader(){
    return "D:\SCOOP\apps\sumatrapdf\current\SumatraPDF.exe"
}

BookFileExtension(){
    return [".pdf", ".epub", ".mobi", ".chm"]
}

再随便新建一个ahk文件。

#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%

#Include %A_ScriptDir%\var.ahk

LoopAssociate("TextEditor", "TextFileExtension")

LoopAssociate("ImageViewer", "ImageFileExtension")

LoopAssociate("BookReader", "BookFileExtension")

LoopAssociate(Editor,FileExtension)
{
   editor := %Editor%() 
   fileExtension := %FileExtension%()
   for index, ext in fileExtension
   {
       Run, SFTA --reg %editor% %ext%
   }
}

如果你有更好的方法,或者不同的意见,也欢迎分享。

8 个赞

不错不错,Scoop 重度用户必备