簡體   English   中英

在Eclipse上執行我的程序時批處理文件運行,但是使用jar文件時出現問題

[英]Batch file runs when executing my program on eclipse but the has issue when jar file is used

我正在嘗試使用Java程序從我的Android手機中提取應用程序。 調用我的批處理文件的代碼是:-

public static void batch(String a,String b) throws InterruptedException
    {
    try {
        fchooser fc=new fchooser();
        String fg=fc.antd;
        String arg1=a;
        String userinp1=b;
       String dir=System.getProperty("user.dir");;


      JOptionPane.showMessageDialog(null, "this is batchrun and path is "+fg);


  Process pan =  Runtime.getRuntime().exec(new String[] {"C:\\test1.bat",arg1,fg});

        pan.waitFor();
        ............

arg1和fg是兩個傳遞給批處理文件的參數。

arg1= /system/app/Chrome
fg= C:\Users\sumeet.p1\Desktop\test2

批處理文件是

cd %2
adb pull %1
pause

在eclipse中,程序運行良好,並將文件提取到fg中指定的位置[在這種情況下-C:\\ Users \\ sumeet.p1 \\ Desktop \\ test2],但是當我使用該程序的jar文件時,文件將被提取到保存jar文件的文件夾,而不是fg中指定的位置。 任何幫助,將不勝感激。 謝謝 :)

我想問題出在您的批處理腳本中的cd %2行。 當您從命令行jar執行目錄時,由於驅動器的更改,目錄可能未按預期更改。

請查看將其更改為cd /d %2如下所示:

cd /d %2
adb pull %1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM