Run batch file from Java code

后端 未结 5 1324
南旧
南旧 2020-11-30 06:56

I am trying to run a batch file that is in another directory from my Java executable. I have the following code :

    try {
        Process p =  Runtime.getR         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 07:27

    try following

    try {
                String[] command = {"cmd.exe", "/C", "Start", "D:\\test.bat"};
                Process p =  Runtime.getRuntime().exec(command);           
            } catch (IOException ex) {
            }
    

提交回复
热议问题