Search code examples
batch-filekill-process

Killing a Batch script from another


I have a script that will call other scripts to run then go back to process. Example: Call a script to ping and when it completes, go back to script.

My issue is I have a script called Bounce.bat

Here is the code:

@Echo off
set IPADDRESS=127.0.0.1
set INTERVAL=60

:PINGINTERVAL
ping %IPADDRESS% -n 1
timeout %INTERVAL%
GOTO PINGINTERVAL

What I need is the command that will kill the Bounce.bat from inside another batch script.

I was going to try killing CMD but that kills the original script as well.

I Have tried experimenting as well as looking at script examples.

Does anyone know what is needed to kill this bat only?


Solution

  • You can use the Command "taskkill" to stop other processes in Windows. You can write something like this in your other batch-file: taskkill /IM MYBATCHFILENAME.bat You can force to kill the process, if you are using the parameter /f at the end of your command.