I couldn't get this to work in Windows 11, sadly. Here's how I got it to work instead:
I found a program that can set file associations here (I found a scoop manifest for it here). But it needs a ProgId to be passed as the file type association, so I modified your batch file to a registry file like so:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\.jar]
@="scoop-javaw"
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw]
@="Java Archive"
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw\DefaultIcon]
@="C:\\Users\\<username-goes-here>\\scoop\\apps\\openjdk\\current\\bin\\javaw.exe,1"
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw\shell]
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw\shell\open]
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw\shell\open\command]
@="\"C:\\Users\\<username-goes-here>\\scoop\\apps\\openjdk\\current\\bin\\javaw.exe\" -jar \"%1\""
Unfortunately, I couldn't get %JAVA_HOME% to work in the registry, so the full path had to be used (replace the two <username-goes-here> with your username/scoop path if on another drive).
Once you've saved this as a .reg file and run it, then finally you can use SetUserFTA:
> SetUserFTA .jar scoop-javaw
The file association should work immediately. But for the DefaultIcon to show up you might need to restart File Explorer. Hope this helps someone.
Edited 05/09/2022 to fix reg file not adding paths to registry (needed to escape each \ and ")
@tech189 Hi. I've customised your reg script and the icon didn't work for me. In my case, just remove ,1 in the DefaultIcon value. I'm using Windows 11 23H2 22631.3737
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\.jar]
@="scoop-javaw"
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw]
@="Java Archive"
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw\DefaultIcon]
- @="C:\\Users\\<username-goes-here>\\scoop\\apps\\openjdk\\current\\bin\\javaw.exe,1"+ @="C:\\Users\\<username-goes-here>\\scoop\\apps\\openjdk\\current\\bin\\javaw.exe"
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw\shell]
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw\shell\open]
[HKEY_CURRENT_USER\Software\Classes\scoop-javaw\shell\open\command]
@="\"C:\\Users\\<username-goes-here>\\scoop\\apps\\openjdk\\current\\bin\\javaw.exe\" -jar \"%1\""
Activity
tech189 commented on Dec 5, 2021
I couldn't get this to work in Windows 11, sadly. Here's how I got it to work instead:
I found a program that can set file associations here (I found a scoop manifest for it here). But it needs a ProgId to be passed as the file type association, so I modified your batch file to a registry file like so:
Unfortunately, I couldn't get %JAVA_HOME% to work in the registry, so the full path had to be used (replace the two <username-goes-here> with your username/scoop path if on another drive).
Once you've saved this as a .reg file and run it, then finally you can use SetUserFTA:
> SetUserFTA .jar scoop-javawThe file association should work immediately. But for the DefaultIcon to show up you might need to restart File Explorer. Hope this helps someone.
Edited 05/09/2022 to fix reg file not adding paths to registry (needed to escape each \ and ")
KevinNitroG commented on Jun 26, 2024
@tech189 Hi. I've customised your reg script and the icon didn't work for me. In my case, just remove ,1 in the DefaultIcon value. I'm using Windows 11 23H2 22631.3737
Thank you very much.
BinToss commented on Sep 1, 2024
Scoop uses Powershell internally. For consistency, should a user-invoked post-install script be made for Powershell?
Also, note assoc is a Command Prompt command. It is not executable outside of cmd.exe. And it should be considered deprecated on Windows 8 and later.
I'm looking into the feasibility of https://github.com/DanysysTeam/PS-SFTA atm