How do I force the Task Manager window closed whenever it opens?

Raymond Chen

A customer wanted to close (or at least hide) the Task Manager window whenever it opens. They did so by setting a timer and periodically running this code:

void FindAndCloseTaskManager()
  HWND taskManagerWindow = FindWindow(nullptr, "Windows Task Manager");
  if (taskManagerWindow) {
    PostMessage(taskManagerWindow, WM_CLOSE, 0, 0);

This code worked on Windows 7, but stopped working on Windows 8.

Well, yeah, because you’re searching for a window by name. The name of the Task Manager window in Windows 7 was Windows Task Manager:

On the other hand, in Windows 8, the window was named simply Task Manager.

And of course, those names apply only to English. If the user’s UI language is German, the name will be Task-Manager with a hyphen.

Whether a user can or cannot run Task Manager is an administrative decision, not an application decision. Use the “Remove Task Manager” group policy.

Bonus chatter: Note that if this customer had their way, the name of Task Manager would be a compatibility constraint.

Bonus bonus chatter: Don’t think you can rely on the window class name either. That is also subject to change.


Discussion is closed.

Feedback usabilla icon