解决java执行 cmd命令报错Exception in thread "main" java.io.IOException: Cannot run program "xxxx": CreateProcess error=2, The system cannot find the file specified


在需要执行的cmd命令头部添加“cmd.exe /c ”字符串,比如原来需要执行“start xxx.bat”,修改之后的命令为“cmd.exe /c start xxx.bat”;这样就可用例如

Runtime.getRuntime().exec(“cmd.exe /c start xxx.bat”);

  方法来启动它


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM