无法从GitBash运行TASKKILL [英] Trouble running TASKKILL from GitBash

查看:374
本文介绍了无法从GitBash运行TASKKILL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 .bashrc 中创建一个函数以在gitbash中运行.我要运行的命令是:

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"'

我将更改"Windows Task Manager"(Windows任务管理器)位,但只是为了显示我正在尝试的内容.当我通过Windows cmd运行该命令(TASKKILL/fi"WINDOWTITLE eq Windows任务管理器")时,它工作正常,但是当我从gitbash运行时,出现以下错误消息:

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.

正如我所说,它在cmd中可以正常工作,所以我认为这与引号有关.我还尝试了以下操作,但也失败了:

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\""

可以将命令放在.bat文件中,然后运行该命令(cmd"/C pathtofile/script.bat"),并且可以正常运行,但我宁愿直接从 .bashrc (如果可能).

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.

推荐答案

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.

这篇关于无法从GitBash运行TASKKILL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆