Trouble running TASKKILL from GitBash

人盡茶涼 提交于 2019-12-10 14:39:52

问题


I'm trying to create a function in my .bashrc to run in gitbash. The command I'm trying to run is:

cmd '/C TASKKILL /fi "WINDOWTITLE eq  Windows Task Manager"'

I'll be changing the "Windows Task Manager" bit, but just to show what I'm trying. The command (TASKKILL /fi "WINDOWTITLE eq Windows Task Manager") works fine when I run it through Windows cmd, but when I run from gitbash, I get this error message:

ERROR: Invalid argument/option - 'eq'.
Type "TASKKILL /?" for usage.

As I said, it works fine in cmd, so I'm thinking it's something to do with the quotation marks. I've also tried the following, which also fails:

cmd "/C TASKKILL /fi \"WINDOWTITLE eq  Windows Task Manager\""

I could put the command in a .bat file and run that (cmd "/C pathtofile/script.bat") and that works, but I'd prefer to run it straight from the .bashrc, if possible.


回答1:


cmd "/C TASKKILL /fi "WINDOWTITLE eq  Windows Task Manager""

It seems like it shouldn't work due to how the quotation marks are nested, but it does.



来源:https://stackoverflow.com/questions/30195353/trouble-running-taskkill-from-gitbash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!