Suppos there are many matlab.exe running on a windows PC, I am trying to terminate all of them, except the one I am working on. I did the following:
curPID = feature('getpid')
%say curPID return 10000.
%then follow:
system('taskkill /F /FI "PID ne 10000" /IM matlab.EXE');
%the above works fine.
But since every time, when I run
curPID = feature('getpid')
in different matlab GUI or m-file, the value of curPID will change, so I tried to pass curPID to the system() function as below:
system('taskkill /F /FI "PID ne curPID"/IM matlab.EXE');
% or
system('taskkill /F /FI "PID ne str2num(curPID)"/IM matlab.EXE');
but they do not work.
How can I pass curPID to taskkill?