1.实现的就是用java实现双击功能,但是bat文件要放在项目根目录下才能执行,这个问题我没解决,希望大家给出答案

2.然后bat文件里面的内容可以参数化,从java代码中把参数传过去。

bat文件内容:

echo off
 SET IP=%1%
 %~nx2 %IP% %~nx3
 @pause

 

java代码

public class test_dat {
     public void runbat(String batName) { 
          try { 
              Runtime.getRuntime().exec("cmd /c start "+batName); 
          }  catch (Exception e) {
              e.printStackTrace();
          }
      } 
     
      @Test
      public  void mytest( ) { 
       test_dat test1 = new test_dat(); 
          String batName = "D:\\CTRV1.1\\DeletePointTool.bat";
          String ip = " ...";
          String exe = " DeletePoint";
          String file = " dataservice1.txt";
          batName += ip+exe+file;
          System.out.print(batName);
          test1.runbat(batName); 
         
          Assert.assertEquals("false", "true");
      }}