2017-09-20 21 views
-1

私は自動テストを実行するのにSikuliを使用しています。テストを実行するための小さなJavaアプリケーションを作成しています。コマンド実行時にCMDウィンドウを閉じる -

Process p = Runtime.getRuntime().exec("cmd /c start /wait C:\\Sikuli\\runIde.cmd -r C:\\Sikuli\\xmlRunner\\runners\\Runner.sikuli --args 5"); 
System.out.println("Waiting for command to be executed"); 
p.waitFor(); 
System.out.println("Command finished"); 

これは始まり:私は他の答えを探してきたが、それらのほとんどは、Javaからのバッチスクリプトを実行しているに関連する、私はCMDからSikuliを実行するには、次のコマンドを持ってjava.Iから全体コマンドを実行する必要があります新しいcmdウィンドウを開き、スクリプトの実行を開始しますが、スクリプトが終了するとcmdウィンドウは閉じません。スクリプトの実行が終了したら自動的にcmdウィンドウを閉じる方法はありますか?

+0

[特定のコマンドプロンプトを閉じる]の可能な複製(https://stackoverflow.com/questions/618528/close-a-particular-command-prompt) –

+0

コマンドの後に 'exit'をチェーンしようとしましたか?これは次のようなものです: 'Process p = Runtime.getRuntime()。exec(" cmd/c start/wait C:\\ Sikuli \\ runIde.cmd -r C:\\ Sikuli \\ xmlRunner \\ runners \\ Runner。 sikuli --args 5&exit ");' – Azeem

+0

コンソールウィンドウを確認してもよろしいですか? – talex

答えて

1

使用cmd /c start /wait cmd /c C:\\Sikuli\\runIde.cmd -r C:\\Sikuli\\xmlRunner\\runners\\Runner.sikuli --args 5

参照ドック:

WAIT  Start application and wait for it to terminate. 
command/program 
      If it is an internal cmd command or a batch file then 
      the command processor is run with the /K switch to cmd.exe. 
      This means that the window will remain after the command 
      has been run. 

      If it is not an internal cmd command or batch file then 
      it is a program and will run as either a windowed application 
      or a console application. 

あなたが直接/Kスイッチが適用されますが、このルールは適用されないときは、プロキシこの呼び出しcmd.exeとさrunIde.cmdを呼び出します。

+0

コマンドを削除/待機すると、スクリプトの実行が終了していなくても "コマンドが完了しました"という行に移動します。 – stewazy

+1

"cmd/c start/wait cmd/cを試してください。C:\\ Sikuli \\ runIde.cmd -r C:\\ Sikuli \\ xmlRunner \\ランナー\\ Runner.sikuli --args 5" ' – talex

+0

ソリューションは働いた:) – stewazy

関連する問題