Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Stop Windows from associating its apps with file types and protocols
- ;via http://www.ghacks.net/2016/10/28/stop-resetting-my-apps/
- ;by LogicDaemon <www.logicdaemon.ru>
- ;This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License <http://creativecommons.org/licenses/by-sa/4.0/deed>.
- #NoEnv
- global pkgBaseKey:="HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages"
- ,assocList:=Object()
- ,appList := Object()
- Loop Reg, %pkgBaseKey%, K
- {
- packageName:=A_LoopRegName
- If(DeniedApp(packageName))
- Loop Reg, %pkgBaseKey%\%packageName%, K
- ListAppAssoc(packageName, A_LoopRegName)
- Else
- Loop Reg, %pkgBaseKey%\%packageName%, K
- If (DeniedApp(A_LoopRegName))
- ListAppAssoc(packageName, A_LoopRegName)
- }
- For appName, ftype in appList {
- list .= appName . ": " . Trim(ftype, ",") . "`n"
- }
- MsgBox 0x24, Deny following associations?, %list%
- IfMsgBox Yes
- {
- For assocID in assocList {
- RegWrite REG_SZ, HKEY_CURRENT_USER\SOFTWARE\Classes\%assocID%, NoOpenWith
- }
- }
- ListAppAssoc(packageName, appName) {
- humanReadableAppName := appName = "App" ? packageName : appName
- Loop Reg, %pkgBaseKey%\%packageName%\%appName%\Capabilities, K ; FileAssociations / URLAssociations / …
- If (EndsWith(A_LoopRegName, "Associations")) {
- Loop Reg, %pkgBaseKey%\%packageName%\%appName%\Capabilities\%A_LoopRegName%
- If ( !(BeginsWith(A_LoopRegName, "ms") || BeginsWith(A_LoopRegName, "microsoft") || BeginsWith(A_LoopRegName, "outlook")) ) {
- RegRead assocID
- assocList[assocID] := ""
- appList[humanReadableAppName] .= A_LoopRegName . ","
- }
- }
- }
- DeniedApp(appName) {
- static DenyApps := [ "Microsoft.MicrosoftEdge"
- ,"Microsoft.Windows.Photos"
- ,"microsoft.windowslive.mail"
- ,"Microsoft.ZuneMusic"
- ,"Microsoft.ZuneVideo"]
- For i,v in DenyApps {
- If (appName = v || BeginsWith(appName, v . "_"))
- return 1
- }
- return 0
- }
- BeginsWith(longstr, shortstr) {
- return SubStr(longstr, 1, StrLen(shortstr)) = shortstr
- }
- EndsWith(longstr, shortstr) {
- return SubStr(longstr, 1-StrLen(shortstr)) = shortstr
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement