I have three batch files, each opening one instance of NUnit
. I want to kill a particular instance of NUnit
when the tests are completed. I am able to fetch the three process ID's for three NUnit
instances.
But is there a way to find out which processId corresponds to which Nunit instance?
Check the image below.
Here it is showing me process ID. But cannot recognize which one is for which instance.
Here is my code in batch for killing the NUnit
process ID.
for /F "tokens=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq nunit.exe"') do (
SETLOCAL ENABLEDELAYEDEXPANSION
set PID=%%b
echo PID StartRun_XXX=!PID!)
::echo before loop
:: Check for TestResult.xml file generation.
:: at the moment when TestResult.xml generated, kill the NUNIT instance and subsequently call OverViewGenerator.bat to generate TestResult.htm
pause
:loop
if exist %~dp0TestResult_%TestCategory%_%TimeStamp%.xml (
cd %~dp0
echo ====================inside if exist------dp0=%~dp0===================
pause
echo PID=!PID!
taskkill /PID !PID! /T
This code abruptly kills any nunit instance.