Windows – taskkill: The process not found

cmd.exekillwindows 7

This happens from time to time: I run a simple taskkill command (as administrator) like this:

taskkill /im sidebar.exe /f

But get the following:

ERROR: The process "sidebar.exe" not found.

Also tried without ".exe". I see the process in Task Manager:

enter image description here

Killing the process from Task Manager works.

I suspect it happens when the process appears stuck (because that's when I kill it), but it's still strange and inconsistent.

I run Windows 7 Professional SP1 64bit.

Best Answer

I'd use tasklist to get the PID of sidebar and taskkill /PID

> tasklist |find /i "sidebar"
sidebar.exe                  17252 Console                    1       209.680 K

> for /f "tokens=2" %A in ('tasklist ^|find /i "sidebar"') Do @Echo PID=%A
PID=17252

> for /f "tokens=2" %A in ('tasklist ^|find /i "sidebar"') Do @Taskkill /PID %A
Related Question