Find out process ID of nunit of particular instance
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.
batch-file nunit taskkill
add a comment |
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.
batch-file nunit taskkill
The for loop will overwrite the PID with all found nunit PIDs, so only the last one persists. In the if code block taskkill will only kill this last one PID.
– LotPings
Nov 26 '18 at 11:57
Why not check the PID's before and after each instance? then you can determine which PID belongs to which respective instance before deciding which to kill.
– Compo
Nov 26 '18 at 13:58
add a comment |
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.
batch-file nunit taskkill
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.
batch-file nunit taskkill
batch-file nunit taskkill
edited Nov 26 '18 at 13:47
freedomn-m
13.3k32148
13.3k32148
asked Nov 26 '18 at 11:31
Karthik SaxenaKarthik Saxena
4410
4410
The for loop will overwrite the PID with all found nunit PIDs, so only the last one persists. In the if code block taskkill will only kill this last one PID.
– LotPings
Nov 26 '18 at 11:57
Why not check the PID's before and after each instance? then you can determine which PID belongs to which respective instance before deciding which to kill.
– Compo
Nov 26 '18 at 13:58
add a comment |
The for loop will overwrite the PID with all found nunit PIDs, so only the last one persists. In the if code block taskkill will only kill this last one PID.
– LotPings
Nov 26 '18 at 11:57
Why not check the PID's before and after each instance? then you can determine which PID belongs to which respective instance before deciding which to kill.
– Compo
Nov 26 '18 at 13:58
The for loop will overwrite the PID with all found nunit PIDs, so only the last one persists. In the if code block taskkill will only kill this last one PID.
– LotPings
Nov 26 '18 at 11:57
The for loop will overwrite the PID with all found nunit PIDs, so only the last one persists. In the if code block taskkill will only kill this last one PID.
– LotPings
Nov 26 '18 at 11:57
Why not check the PID's before and after each instance? then you can determine which PID belongs to which respective instance before deciding which to kill.
– Compo
Nov 26 '18 at 13:58
Why not check the PID's before and after each instance? then you can determine which PID belongs to which respective instance before deciding which to kill.
– Compo
Nov 26 '18 at 13:58
add a comment |
1 Answer
1
active
oldest
votes
Your best bet is probably distinguishing nunit
processes when they are launched.
It is possible to obtain PID of a process started through WMIC:
set "tab=" <<<<<<<<<<<< PLEASE insert TAB after '='
set "pid="
for /F "usebackq tokens=1,2 delims=;=%tab% " %%i in (
`wmic process call create "nunit.exe"^, "C:workingdir"`
) do if %%j gtr 0 set pid=%%j
(copied from this answer)
Then you can save PID into a file
echo set "PID=%pid%" >yourfile.bat
To kill the process just run the script to obtain the variable
call yourfile.bat
taskkill /pid %pid%
taskkill /f /pid %pid%
del /y yourfile.bat
See also: How to get the output of "wmic process call create"
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480186%2ffind-out-process-id-of-nunit-of-particular-instance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your best bet is probably distinguishing nunit
processes when they are launched.
It is possible to obtain PID of a process started through WMIC:
set "tab=" <<<<<<<<<<<< PLEASE insert TAB after '='
set "pid="
for /F "usebackq tokens=1,2 delims=;=%tab% " %%i in (
`wmic process call create "nunit.exe"^, "C:workingdir"`
) do if %%j gtr 0 set pid=%%j
(copied from this answer)
Then you can save PID into a file
echo set "PID=%pid%" >yourfile.bat
To kill the process just run the script to obtain the variable
call yourfile.bat
taskkill /pid %pid%
taskkill /f /pid %pid%
del /y yourfile.bat
See also: How to get the output of "wmic process call create"
add a comment |
Your best bet is probably distinguishing nunit
processes when they are launched.
It is possible to obtain PID of a process started through WMIC:
set "tab=" <<<<<<<<<<<< PLEASE insert TAB after '='
set "pid="
for /F "usebackq tokens=1,2 delims=;=%tab% " %%i in (
`wmic process call create "nunit.exe"^, "C:workingdir"`
) do if %%j gtr 0 set pid=%%j
(copied from this answer)
Then you can save PID into a file
echo set "PID=%pid%" >yourfile.bat
To kill the process just run the script to obtain the variable
call yourfile.bat
taskkill /pid %pid%
taskkill /f /pid %pid%
del /y yourfile.bat
See also: How to get the output of "wmic process call create"
add a comment |
Your best bet is probably distinguishing nunit
processes when they are launched.
It is possible to obtain PID of a process started through WMIC:
set "tab=" <<<<<<<<<<<< PLEASE insert TAB after '='
set "pid="
for /F "usebackq tokens=1,2 delims=;=%tab% " %%i in (
`wmic process call create "nunit.exe"^, "C:workingdir"`
) do if %%j gtr 0 set pid=%%j
(copied from this answer)
Then you can save PID into a file
echo set "PID=%pid%" >yourfile.bat
To kill the process just run the script to obtain the variable
call yourfile.bat
taskkill /pid %pid%
taskkill /f /pid %pid%
del /y yourfile.bat
See also: How to get the output of "wmic process call create"
Your best bet is probably distinguishing nunit
processes when they are launched.
It is possible to obtain PID of a process started through WMIC:
set "tab=" <<<<<<<<<<<< PLEASE insert TAB after '='
set "pid="
for /F "usebackq tokens=1,2 delims=;=%tab% " %%i in (
`wmic process call create "nunit.exe"^, "C:workingdir"`
) do if %%j gtr 0 set pid=%%j
(copied from this answer)
Then you can save PID into a file
echo set "PID=%pid%" >yourfile.bat
To kill the process just run the script to obtain the variable
call yourfile.bat
taskkill /pid %pid%
taskkill /f /pid %pid%
del /y yourfile.bat
See also: How to get the output of "wmic process call create"
answered Nov 26 '18 at 23:28
Jack WhiteJack White
33416
33416
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480186%2ffind-out-process-id-of-nunit-of-particular-instance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The for loop will overwrite the PID with all found nunit PIDs, so only the last one persists. In the if code block taskkill will only kill this last one PID.
– LotPings
Nov 26 '18 at 11:57
Why not check the PID's before and after each instance? then you can determine which PID belongs to which respective instance before deciding which to kill.
– Compo
Nov 26 '18 at 13:58