2017-05-16 10 views
0

私はプロセスを終了し、後で別のプロセスを実行する方法を探しています。これは、同じバッチファイルで実行する必要があります。そして、プロセスを終了する唯一の方法は、CTRL + Cを押してから、その後にYと言うことです。Cmdバッチファイルの設定

私がしたいことは、バッチファイルが自動的に行うことです。 CMD:CTRL +C CMD:Y

コールのx.exe

だから私の質問は、私はプログラム的にバッチスクリプトでこれらのステップを行うのですかですか?

ご協力いただきありがとうございます。

+0

あなたは多くの方法で動くことができる 'taskkill'でタスクを終了できますが、おそらく最も簡単なのは' tasklist'を使って簡単に取得できるプロセスIDです(PID) – Magoo

+0

EXIT/bでスクリプトを停止できます。 – Sascha

+0

@Saschaバッチを終了する必要はありません。なぜなら、新しいバッチコールが後で起こるからです。ですから、私はプロセスを終了し、その後に新しいプロセスを作成したいと思います。 – StrawHat

答えて

1

これを行うには、まずコマンドtaskkillを使用します。これにより、ファイルのコードで指定したプロセスが終了します。それでも問題が解決しない場合は、taskkill /?を入力するときに指定したパラメータの1つを入力してみてください。

/S system   Specifies the remote system to connect to. 

/U [domain\]user Specifies the user context under which the 
         command should execute. 

/P [password]  Specifies the password for the given user 
         context. Prompts for input if omitted. 

/FI filter   Applies a filter to select a set of tasks. 
         Allows "*" to be used. ex. imagename eq acme* 

/PID processid  Specifies the PID of the process to be terminated. 
         Use TaskList to get the PID. 

/IM imagename  Specifies the image name of the process 
         to be terminated. Wildcard '*' can be used 
         to specify all tasks or image names. 

/T      Terminates the specified process and any 
         child processes which were started by it. 

/F      Specifies to forcefully terminate the process(es). 

次に、callコマンドを使用します。私は一度もこのコマンドを使用しなければならなかったので、私の定義は100%正しいとは限りません。ごめんなさい。

callコマンドは、別のバッチファイルを実行するために使用されます。このように使用されなければならない:CALL [drive:][path]filename [batch-parameters]。バッチパラメータは、ファイルに必要な重要な情報を指定するために使用されます。ファイル拡張子を有効にしている場合、callコマンドはラベルをターゲットとして受け入れます。

ここに行きます。

関連する問題