Close chrome from bat file

2019-05-11 17:26发布

问题:

I am trying to kill chrome from bat file. Tried

TASKKILL /IM chrome.exe /F

but it doesnt close the chrome. What is the correct way to do that ?

回答1:

You'll want to use the same command, but with the /T argument, like so:

taskkill /F /IM chrome.exe /T

The /T argument kills the process and all of its child processes. Effectively, it should close all processes with the same process name that you provide in the argument list.

If you'd like to suppress errors/output, pipe the ouput to nul, like this:

taskkill /F /IM chrome.exe /T > nul

Regardless of the method you use, you must run the batch file as an Administrator to kill the chrome.exe processes.



回答2:

taskkill /F /IM chrome.exe /T

or

taskkill /F /IM chrome* /T

{Explanation:

taskkill (to kill the processes),

/F (forcefully terminate the process),

/IM (Image Name of the process to be terminated. '*' wildcard can be sure to specify all the tasks or image names)

/T (Terminate all child of the image or process) )

share|improve this answer
1

this code is working in my script well:

taskkill /f /im chrome.exe /fi "username eq domain\user.name"
share|improve this answer
  • Please explain why the command in the question does not work and why your command does work. – Julian Aug 2 '16 at 9:52
  • Im running script as administrator and filtering process to kill by user name. Maybe this are the reasons. – Dávid Miškovič Aug 3 '16 at 6:24

Your Answer

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged batch-file command-line cmd or ask your own question.

收藏的人(0)

Ta的文章 更多文章
登录 后发表评论
0条评论
还没有人评论过~