Run batch file from Java code

后端 未结 5 1331
南旧
南旧 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:46

    import java.lang.Runtime;
    
    Process run = Runtime.getRuntime().exec("cmd.exe", "/c", "Start", "path of the bat file");
    

    This will work for you and is easy to use.

提交回复
热议问题