2012-05-11 142 views
0

需要幫助來調用java交互式的批處理文件,它不應該在新窗口中打開。嘗試使用Runtime調用--- cmd/c啓動batchfilename ---但它在新窗口中打開。我需要在調用批處理文件的同一個窗口中關注和執行調用批處理文件。從java運行交互式bat文件?

+0

請寫一些執行'運行時'的程序的代碼。 –

回答

1

Windows有一個啓動命令:

C:\>start /? 
Starts a separate window to run a specified program or command. 

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] 
     [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] 
     [/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program] 
     [parameters] 

    "title"  Title to display in window title bar. 
    path  Starting directory 
    B   Start application without creating a new window. The 
       application has ^C handling ignored. Unless the application 
       enables ^C processing, ^Break is the only way to interrupt 
       the application 
    I   The new environment will be the original environment passed 
       to the cmd.exe and not the current environment. 
    MIN   Start window minimized 
    MAX   Start window maximized 
    SEPARATE Start 16-bit Windows program in separate memory space 
    SHARED  Start 16-bit Windows program in shared memory space 
    LOW   Start application in the IDLE priority class 
    NORMAL  Start application in the NORMAL priority class 
    HIGH  Start application in the HIGH priority class 
    REALTIME Start application in the REALTIME priority class 
Press any key to continue . . . 

嘗試運行開始(而不是CMD)。如果這沒有幫助你可以捕捉/輸出用戶和管道到Process