亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法使用 java servlet 在 cmd 中打開或執行命令

無法使用 java servlet 在 cmd 中打開或執行命令

aluckdog 2021-10-13 10:19:32
想使用 java servlet 執行 echot.BAT 文件。我使用了以下代碼。Process croppingProcess =  Runtime.getRuntime()                .exec("C:Windows/system32/cmd /c echot.BAT", null, new File("C:restapi_bat/echot"));                int processOutput = croppingProcess.waitFor();                if(processOutput == 0){                    success = true;            //do your work here        }但得到錯誤"C:Windows/system32/cmd" (in directory "C:restapi_bat\echot"): CreateProcess error=267, 目錄名無效C:\restapi_bat 中的文件 echot.BAT注意:使用 tomcat 7
查看完整描述

2 回答

?
月關寶盒

TA貢獻1772條經驗 獲得超5個贊

使用escape和Start,bat執行的解決方法如下


Process croppingProcess =  Runtime.getRuntime()

                .exec("C:\\Windows\\System32\\cmd.exe /C Start C:\\restapi_bat\\echot ");

                int processOutput = croppingProcess.waitFor();

                if(processOutput == 0){

                    success = true;

            //do your work here

        }


查看完整回答
反對 回復 2021-10-13
  • 2 回答
  • 0 關注
  • 119 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號