简体   繁体   English

从包含字符串的BAT文件中杀死特定的cmd.exe

[英]Kill specific cmd.exe from BAT file containing string

I am currently running into an issue where a "cmd.exe" process remains active despite a particular service being stopped. 我目前遇到一个问题,尽管停止了特定的服务,但“ cmd.exe”进程仍然处于活动状态。 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. 由于我的自动化脚本是从BAT文件运行的,因此我相信可以用TASKKILL杀死它。 Using "Process Explorer", I searched for the folder name and it was able to locate the "cmd.exe" that was using it. 使用“ Process Explorer”,我搜索了文件夹名称,并且能够找到使用它的“ cmd.exe”。 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 /? , wmic process /? wmic process /? , wmic process get /? wmic process get /? , wmic process call /? wmic process call /? , wmic process set /? wmic process set /? , wmic /format /? wmic /format /? , wmic /node /? wmic /node /? , etc . etc

Like is % 0 or more characters and _ is a single character. Like% 0或更多字符,而_是单个字符。 Otherwise =, <>, <, >, <=, => . 否则=, <>, <, >, <=, =>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM