Is there a way to change a default program by java, cmd, or regedit?

1

I'm developing a system in java, but from it I should change the default program to open .pdf on the switch. In Windows 10 it opens by default on the Edge, however from the system it should change to Adobe.

I've already tried cmd with the assoc command (restarting the computer later):

assoc .pdf=AcrodRd32.exe

or

assoc .pdf=AcroExch.Document.DC

I've also tried through regedit with the script (also restarting the computer later):

===================
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.pdf]
@=".pdf=AcroExch.Document.DC"
"Content Type"="application/pdf"

[HKEY_CLASSES_ROOT\.pdf\OpenWithList]

[HKEY_CLASSES_ROOT\.pdf\OpenWithList\AcrodRd32.exe]
@=""
===================

I tested the script in HKEY_CLASSES_ROOT.pdf \ as in HKEY_CLASSES_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ FileExts but none worked.

I believe that direct from java has no way to change. Anyone have any ideas how to make this change?

    
asked by anonymous 28.05.2017 / 16:24

1 answer

1

This site shows something not very encouraging.

It seems that from Windows 10, this functionality has been removed:

  In Windows 10, all applications - both Classic and Universal - will not be able to show a window asking if you want to switch your default program - just Windows. " - Translated from English

Perhaps making a classic application (I'm not sure if that means just compiling for older systems or not) you can still take advantage of this prompt :

Butanywayitwillonly"teach" the user to change the default program and not "offer" to switch automatically.

Even so, in Java this is not possible without some "gambiarras", since .jar is not a valid Windows application. One possible solution is to turn .jar into an .exe - this program not only creates a .jar executable but also set the default program .

But I think we're out of luck!

Sources in Soen:
Set default program for extension after msi installation
Use the Java application as the Default Program for a particular file type?

    
31.05.2017 / 05:37