0

I want to check if execel.exe is running on windows, then kill it.

here how I check if the process is running:

tasklist | findstr /I excel

how can I write a shell script to check if it's running, then kill it, else do sth else

if tasklist | findstr /I excel
   taskkill /F /IM excel
else
   ...
fi

I am trying for notepad here:

tasklist | findstr /I notepad++.exe
if [ -z "tasklist | findstr /I notepad++.exe" ] || [ echo "Empty" ];then
    echo "The process is not running";
else
    echo "The process is running";
    taskkill /F /IM notepad++.exe;
fi

The problem is that if the process i not running I get an error. but if the process is running everything works fine.

user3122648
  • 887
  • 2
  • 8
  • 21

0 Answers0