We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x
Private

Windows 10: kill a process

Luis Diaz
Luis Diaz asked
on
High Priority
44 Views
Last Modified: 2020-05-19
Hello experts,

I use on a daily basis the following sequence to kill a process.
Light, simple, swift and efficient:
20200519_171449-screenshot.png
From an experts angle, do you see potential risk (computer damage etc..) by proceeding like this?

Thank you for your help.
Comment
Watch Question

bbaoIT Consultant
CERTIFIED EXPERT
Commented:
that's a rough way to terminate a process, which doesn't give the target process any chance to properly clean up the memory, cache and temp data on the disk. it may look like an efficient way, but it may leave some rubbish behind. in my opinion, that's the last resort, only necessary when the target process is out of control such as no response to any user interaction.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
If you're using that daily something is wrong.  You should not want / have to kill a process like that frequently, it should be a last resort.

Killing a process can open you up to corrupted data, or files that are locked until a reboot, etc.

You want to get to the root of the problem of why task(s) need killing.


»bp
Joe WinogradDeveloper
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2018

Commented:
Hey, Bill..."frequently" ==> "infrequently" :)
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
taskkill.exe, when used like that, is, as far as I know, the same as clicking the X button of the program's window, that is, it sends a WM_CLOSE to the program. So not too bad (but still fells somewhat strange ...).
Just don't use "taskkill.exe /f" on a regular basis - this kicks out the process no matter what, and without informing it previously.
Open Notepad with an empty document, enter a few characters, and check the difference between these two commands:
taskkill.exe /im notepad.exe
taskkill.exe /im notepad.exe /f

Open in new window

Harjit DhaliwalSysAdmin
CERTIFIED EXPERT

Commented:
Are you running multiple tabs in Chrome? I recommend the use of an extension called "The Great Suspender" which suspends the processes of inactive tabs until they are used again. Check to make sure you are current with your version of Chrome. 
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
oBdA is right (no surprise there), if the task involved is indeed not hung and can respond to the WM_CLOSE that TASKKILL sends to it, then that is like closing the application normally via the red X or File -> Close, etc.

My comment was more targeted to the case where you have tried normal closing and it didn't work, so you resort to killing it more forcefully with TASKKILL.  Which may be called for depending on the circumstances.  Sometimes if I am debugging some VBS code that automates an Office app line Excel, and I get an error that causes the code to terminate in the middle of the process, the Excel.exe process can be "stuck" running even though there is no UI available to interact with it (during automation it's common to start Excel hidden).  In these cases I do typically use Task Manager or TASKKILL to remove the process.  Depending on what it was doing I may have to recover etc when I restart Excel.


»bp
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Luis, why like that?
Luis DiazIT consultant

Author

Commented:
Thank you for your insight.

The purpose of the question is to know if there is a risk of using this command. I don't have any process that disturb me. I use this process because most of the time I work with multiple applications and documents. By proceeding as Bill mentioned
closing the application normally via the red X or File -> Close, etc
, I lost time and can be time consuming specially when I am in a hurry and I need to rapidly join a meeting.

But if you validate that it is the same process as:
closing the application normally via the red X or File -> Close, etc
I am more than happy.

I note the fact that taskkill.exe  "processname.exe" /im  /f
don't prompt and can be critical if you are working on a document and you should save it

Regards,
Luis.
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
I guess we all work differently, but I would still prefer (myself) to visit each application / document I wanted to close and doing it via the normal UI process.  Just in case I left something in a state I don't want it in when I close the file, or the application, etc.  But I don't keep that many things open at one time, as much for performance and screen clutter.  It takes very little time to restart things when I need them again here.


»bp
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
taskkill /f is not only critical when working on a document. It prevents any controlled exit of the application. The process will be kicked out by the OS without ado. Depending on the process killed, it can result in an instable environment, it can result in file handles left open, in lost configuration data of the process, whatever.
This is only a last resort if a process crashed and doesn't respond anymore.

taskkill without /f should be fine (if the program you close doesn't mind being closed by the X).
And you've seen the right-click option in Windows 10's taskbar "X Close all Windows" to close a group of open programs (like 10 open PS consoles) all at once?
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
One other thing to note, I also use [WIN] + [TAB] a bit more lately than I used to, it's a bit more interesting / useful.  It will show thumbnails of open windows and you can very easily close one of more selectively there by clicking the "X" in the upper right of the thumbnail.

Cool little utility here too...



»bp
CERTIFIED EXPERT
Commented:
If you run that command as admin, you'd also kill that process for any other users connected to your machine.  Not sure if that's a real issue for you, but thought I'd point that out.
Luis DiazIT consultant

Author

Commented:
Thank you very much for those useful insight.

@Bill:https://www.ntwind.com/software/closeall.html is an excellent proposal. I installed and start using.

I will proceed like this:
Daily basis:
  • Use ntwind or taskkill without /f
Last resort:
 
  • taskkill /f
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.