从包含字符串的BAT文件中杀死特定的cmd.exe [英] Kill specific cmd.exe from BAT file containing string

查看:849
本文介绍了从包含字符串的BAT文件中杀死特定的cmd.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前遇到一个问题,即cmd.exe进程保持活动,尽管特定的服务被停止。这反过来会导致自动化脚本的问题,该脚本对文件夹执行操作,阻止其重命名/移动/等。



由于我的自动脚本从BAT文件,我相信我可以杀死它与TASKKILL。使用Process Explorer,我搜索了文件夹名称,它能找到使用它的cmd.exe。我没有找到一种方法来自动化,虽然没有一些类型的包含字符串。我的伪示例是...

  taskkill / IM cmd.exe / FINAME contains TC38247178584278321320778
php\\ \\ php.exe migration.php TC38247178584278321320778



>

  wmic process wherecommandline like'%TC38247178584278321320778%'get name 

以查看下一个命令将会杀死

  wmic process where命令行喜欢'%TC38247178584278321320778%'调用终止

请参阅 wmic /? wmic process /? wmic process get /? wmic process call /? wmic process set /? / format /? wmic / node /? etc



喜欢 0个或更多字符和 _ 是一个单个字符。否则 =,<>,<,>,< =,=>


I am currently running into an issue where a "cmd.exe" process remains active despite a particular service being stopped. This in turn is causing problems for an automated script that performs actions on the folder, preventing it from being renamed/moved/etc.

As my automated script runs from a BAT file, I believe I can kill it with TASKKILL. Using "Process Explorer", I searched for the folder name and it was able to locate the "cmd.exe" that was using it. I am having trouble finding a way to automate this though without some type of "Contains String". My pseudo example is...

taskkill /IM cmd.exe /FI "NAME contains TC38247178584278321320778"
php\php.exe migration.php TC38247178584278321320778

解决方案

wmic process where "commandline like '%TC38247178584278321320778%'" get name

to see what next command will kill

wmic process where "commandline like '%TC38247178584278321320778%'" call terminate

See wmic /?, wmic process /?, wmic process get /?, wmic process call /?, wmic process set /?, wmic /format /?, wmic /node /?, etc.

Like is % 0 or more characters and _ is a single character. Otherwise =, <>, <, >, <=, =>.

这篇关于从包含字符串的BAT文件中杀死特定的cmd.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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