Windows Open With Dialog from Java

40 Views Asked by At

I need to call the Windows Open With dialog from my Java code. I used to use this line:

Runtime.getRuntime().exec("RUNDLL32.EXE SHELL32.DLL,OpenAs_RunDLL " + absolute_file_path)

However, with Java JDK 20, my compiler now complains that form of exec is deprecated. I see that ProcessBuilder is the recommended replacement, and I've been able to use it for other Windows command-line execution. However, I've been unable to get this to work for Open With:

ProcessBuilder builder = new ProcessBuilder("RUNDLL32.EXE","SHELL32.DLL,OpenAs_RunDLL", absolute_file_path);
builder.start();

What do I need to do to get this to work with ProcessBuilder?

0

There are 0 best solutions below