|
Answer» Dear All Expert,
i'v run 2 java file so that TASKLIST option is showing two image Name (java.exe) and different PID (like as 2460 & 3789) now suppose if i WANT to do stop one (java.exe) whose PID is 2460. then how could i recognized that i'v closed java.exe file of a particulare PID (2460)......?
pls let me know help me
Best Regards Ashutoshyou should do your own homework. It's to help you learn. thanx for UR suggestion.........!!Dear All Members,
i'm running batch file(start.bat) which run my java aaplication and this batch file stored at C:\ABC\XYZ\start.bat with PID like as 1792 and another batch file with same name run from this location C:\CMD\MNC\start.bat with PID like as 8967 and another batch file with same name run from this location C:\JKL\GHI\start.bat with PID like as 4356 now i make another batch file (kill.bat) and stored at each location. Now i run kill.bat from ( C:\CMD\MNC\kill.bat ) this location.
my question is this that how could i found the PID of start.bat which is run from this location (C:\CMD\MNC\start.bat) and kill this process by KILL.bat file.....?
If anybody help me. PLEASE revert back to me. I'v been tried two file that is KILL_FIRST.bat and KILL_LAST.bat but didnot get success.
KILL_FIRST.bat
@echo off REM **** KILL_FIRST.BAT **** set TASKNAME=java.exe SETLOCAL ENABLEDELAYEDEXPANSION
echo Task LIST before KILL...
set TASKTOTAL=0 for /F "tokens=1-2" %%A in ('tasklist.exe /nh /fi "imagename eq %TASKNAME%"') do ( set /A TASKTOTAL=!TASKTOTAL!+1 echo [Task !TASKTOTAL! is "%%A %%B"] ) echo [Task %TASKTOTAL% is last] echo IF START if %TASKTOTAL%==0 goto :eof set TASKCOUNT=0 for /F "tokens=1-2" %%A in ('tasklist.exe /nh /fi "imagename eq %TASKNAME%"') do ( set /A TASKCOUNT=!TASKCOUNT!+1 if !TASKCOUNT!==1 taskkill.exe /F /PID %%B ) echo Task list after KILL... set TASKTOTAL=0 for /F "tokens=1-2" %%A in ('tasklist.exe /nh /fi "imagename eq %TASKNAME%"') do ( set /A TASKTOTAL=!TASKTOTAL!+1 echo [Task !TASKTOTAL! is "%%A %%B"] ) echo LOOP-3 END echo [Task %TASKTOTAL% is last]
KILL_LAST.bat
@echo off REM **** KILL_LAST.BAT **** set TASKNAME=java.EXE SETLOCAL ENABLEDELAYEDEXPANSION
echo Task list before KILL_LAST... set TASKTOTAL=0 for /F "tokens=1-2" %%A in ('tasklist.exe /nh /fi "imagename eq %TASKNAME%"') do ( set /A TASKTOTAL=!TASKTOTAL!+1 echo [Task !TASKTOTAL! is "%%A %%B"] ) echo [Task %TASKTOTAL% is last]
if %TASKTOTAL%==0 goto :eof set TASKCOUNT=0 for /F "tokens=1-2" %%A in ('tasklist.exe /nh /fi "imagename eq %TASKNAME%"') do ( set /A TASKCOUNT=!TASKCOUNT!+1 if !TASKCOUNT!==!TASKTOTAL! taskkill.exe /F /PID %%B )
echo Task list after KILL_LAST... set TASKTOTAL=0 for /F "tokens=1-2" %%A in ('tasklist.exe /nh /fi "imagename eq %TASKNAME%"') do ( set /A TASKTOTAL=!TASKTOTAL!+1 echo [Task !TASKTOTAL! is "%%A %%B"] ) echo [Task %TASKTOTAL% is last]
Can anyone help me on this topic pls..........?
Best Regards AshutoshWhy did you post this long question in 2 different threads? toshashu123, can you just ask all of your questions in one thread, instead of asking similar questions all over the place?
|