Launch associated program or show “Open with” dialog from another program

后端 未结 3 770
耶瑟儿~
耶瑟儿~ 2020-11-30 10:48

Under Window Seven, the following command displays a dialog box then terminates without any other action, why?

The expected effect is launching the associated progra

3条回答
  •  再見小時候
    2020-11-30 11:28

    The solution is very simple: cmde.exe start

    Here is the Java code which embed the command:

    private void open( File file ) {
       try {
          final String cmd =
             String.format( "cmd.exe /C start %s", file.getAbsolutePath());
          Runtime.getRuntime().exec( cmd );
       }
       catch( final Throwable t ) {
          t.printStackTrace();
       }
    }
    

    When .project is selected the following dialog is shown:

    enter image description here

    and when the radio button at the bottom is chosen the following dialog is shown:

    enter image description here

    That's exactly what I want.

提交回复
热议问题