ChrisTitusTech / winutil

Chris Titus Tech's Windows Utility - Install Programs, Tweaks, Fixes, and Updates
MIT License
20.89k stars 1.29k forks source link

Unable to set the default program for .svg file extensions after uninstalling Edge #1663

Closed jjamesmartiin closed 6 months ago

jjamesmartiin commented 6 months ago

Describe the bug Once I've uninstalled Edge using winutil, the option to set a default program for the .svg file extension is missing even after reinstalling Edge from the same script.

To Reproduce Steps to reproduce the behavior:

  1. Uninstall Edge from the "tweaks" menu under "advanced tweaks - caution"
  2. Trya and set the default program for a .svg by right-clicking on it and using the "open with" menu
  3. Unable to see the "always" button, only "just once"
  4. Can try to type "edge" into the powershell window at the end of the uninstall script to reinstall, but that only opens the .svg with Edge, I still can't set it to another program.

Expected behavior I would expect to be able to still set the default app for opening a .svg even if Edge was uninstalled, but even if that's tied to the file extension somehow, I would expect reinstalling it to fix the behavior.

Screenshots

image

og-mrk commented 6 months ago

I've tested the issue you're facing, and I have Edge uninstalled using WinUtil a few days ago, but didn't noticed this issue (Mainly because I don't work with many .svg files), and this issue is somewhat difficult to solve, due to Microsoft way of handling Default apps for File Extensions, now WinUtil is, at the end of the day, a PowerShell Script, and there're limitation that (us users) not be aware of, but what I've found, after a few google searches, is that Microsoft apparently Encrypts the Default app to use as a HASH Value in Registry, which means that it's Really hard to change the default app for any File Type through Registry (One method that came to me). Source: https://superuser.com/questions/1748620/on-windows-10-is-there-a-file-i-can-modify-to-configure-the-default-apps

If anyone more experienced have another method to use to solve this issue, feel free to post your ideas in this Issue Ticket, and when solved it'll introduce a cool way to configure default apps through WinUtil, which'd be very nice indeed.

jjamesmartiin commented 6 months ago

Microsoft apparently Encrypts the Default app to use as a HASH Value in Registry, which means that it's Really hard to change the default app for any File Type through Registry (One method that came to me). Source: https://superuser.com/questions/1748620/on-windows-10-is-there-a-file-i-can-modify-to-configure-the-default-apps

If anyone more experienced have another method to use to solve this issue, feel free to post your ideas in this Issue Ticket, and when solved it'll introduce a cool way to configure default apps through WinUtil, which'd be very nice indeed.

A user on https://stackoverflow.com/questions/17946282/whats-the-hash-in-hkcu-software-microsoft-windows-currentversion-explorer-filee posted a pastebin to AssocHashGen.cpp which I'm testing out now.

og-mrk commented 6 months ago

Once we can verify that the algorithm outputs Correct Hashes for all apps, on multiple different users, we can convert this algorithm into PowerShell Code, and in theory, make such feature possible.

If you've any updates on your discoveries @jjamesmartiin, feel free to post them here, many thanks in advance for sharing your time/skills with this project šŸ¤

jjamesmartiin commented 6 months ago

I was able to get the .svg extension working again using https://kolbi.cz/blog/2017/10/25/setuserfta-userchoice-hash-defeated-set-file-type-associations-per-user/, but unfortunately it's closed source. I'm still going to try out https://github.com/DanysysTeam/PS-SFTA which is an open source powershell native alternative. I'll update with the status of that soon.

jjamesmartiin commented 6 months ago

I can confirm that I was able to fix the issue by using https://github.com/DanysysTeam/PS-SFTA.

After downloading the powershell file and importing it with . ~\Downloads\SFTA.ps1 you can run the functions that were defined like Get-FTA and Set-FTA.

The best way to get the ProgID for an unknown program was to use the GUI to set the program you're trying to find as the default app for a different file extension than the one you're trying to set, then you can read the associated ProgID for the extension we set from the GUI using Get-FTA. If it's already the default for some other extension then you don't need to set anything and could just read it using Get-FTA.

The command I needed in a oneliner: powershell -ExecutionPolicy Bypass -command "& { . .\SFTA.ps1; Set-FTA 'Applications/inkscape.exe' '.svg'}"

og-mrk commented 6 months ago

Hello there @jjamesmartiin, Thanks again for your efforts to making this idea possible, I've looked at the code for PS-SFTA Project, as well as the C++ code that contains the reversed engineered algorithm code, my only issue so far is that Both have what's often referred to as "Magic Numbers", or Literal Numbers found in the source code, and isn't very clear on Why it is there, and How was this Number was even decided in first place.

If you've any ideas on these Magic Numbers, feel free to share your thought about it.

github-actions[bot] commented 6 months ago

Closed due to inactivity