Quantcast
Channel: MSDN Blogs
Viewing all articles
Browse latest Browse all 5308

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

$
0
0


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:


SRC="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_technet/virtualization/WindowsLiveWriter/DynamicMemoryComingtoHyperVPart3_A923/Win%207%20Task%20Manager%20_2_thumb_bcd1746d-4a8f-4e5b-b83d-19d89dfbff6f.png">


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


SRC="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/54/33/metablogapi/1488.clip_image004_thumb_6633EC51.jpg">


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
.


Viewing all articles
Browse latest Browse all 5308

Trending Articles