Closing an open Task Manager window
-
How to close an Task Manager window which is already open. Is there a way to get the process id of the Task Manager and end it? Anykind of help is highly appreciated. CHEERS I.T. D.U.D.E
-
How to close an Task Manager window which is already open. Is there a way to get the process id of the Task Manager and end it? Anykind of help is highly appreciated. CHEERS I.T. D.U.D.E
-
How to close an Task Manager window which is already open. Is there a way to get the process id of the Task Manager and end it? Anykind of help is highly appreciated. CHEERS I.T. D.U.D.E
Or just use something like this, which is all managed code:
Process[] procs = Process.GetProcessesByName("taskmgr");
if (procs != null)
foreach (Process proc in procs)
proc.Kill();Microsoft MVP, Visual C# My Articles
-
Or just use something like this, which is all managed code:
Process[] procs = Process.GetProcessesByName("taskmgr");
if (procs != null)
foreach (Process proc in procs)
proc.Kill();Microsoft MVP, Visual C# My Articles
I try to avoid
Kill
ing processes unless it's a last resort. To quote MSDN: "Data edited by the process or resources allocated to the process can be lost if you call Kill. Kill causes an abnormal process termination and should be used only when necessary." The task manager opens handles to the performance counters amongst other things. JustKill
ing it may not release them cleanly. Latter versions of Windows are better at handling reclaiming such resources, but I feel it's better to play nice.Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me -
I try to avoid
Kill
ing processes unless it's a last resort. To quote MSDN: "Data edited by the process or resources allocated to the process can be lost if you call Kill. Kill causes an abnormal process termination and should be used only when necessary." The task manager opens handles to the performance counters amongst other things. JustKill
ing it may not release them cleanly. Latter versions of Windows are better at handling reclaiming such resources, but I feel it's better to play nice.Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - meThere's always
Process.CloseMainWindow
. The idea is to avoid P/Invoking when possible since it can help lead to more portable code. It was an example and I would hope that for most code samples I post they just don't take them as-is - the ol' copy and paste. I try to teach people, not hand them the answers so they can continue their pursuit in ignorance. You may a good point, though.Microsoft MVP, Visual C# My Articles
-
There's always
Process.CloseMainWindow
. The idea is to avoid P/Invoking when possible since it can help lead to more portable code. It was an example and I would hope that for most code samples I post they just don't take them as-is - the ol' copy and paste. I try to teach people, not hand them the answers so they can continue their pursuit in ignorance. You may a good point, though.Microsoft MVP, Visual C# My Articles
Yes, and I believe that TaskMan.exe is a well-formed Windows app.
Process.CloseMainWindow
(MSDN) "in a well-formed application, closes child windows and revokes all running message loops for the application. The request to exit the process by calling CloseMainWindow does not force the application to quit...The behavior of CloseMainWindow is identical to that of a user closing an application's main window using the system menu. Therefore, the request to exit the process by closing the main window does not force the application to quit immediately."Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me