【Windows】bat杀掉指定进程

bat编写

打印

关闭打印

echo off

当前行不打印

@

常常看到bat文件开头就是 @ echo off

变量

设置变量

set a=5

取变量

%a%

%号转义

%%

例如SQL like '%name%'   在bat里写为 like '%%name%%'

函数

:funcname  //函数名称 
%1 //取第一个参数
%2 //取第二个参数
//写你的代码
@ goto:eof //函数结束固定写法

函数调用

call ::funcname

//传参
call ::funcname param1 param2 

跳转

:start
echo start

:middle
echo middle

:user
echo user

:end

代码按顺序执行,但是可以使用goto :标记 跳转,不执行跳过的代码

:start
echo start
goto user //middle将被跳过,直接执行:user以及:user后面的

:middle
echo middle

:user
echo user

:end

查询进程号并杀掉

wmic process where (commandline like "%%org.elasticsearch.bootstrap.Elasticsearch%%" and not name="wmic.exe") delete
wmic process where (commandline like "%%geofence-server%%" and not name="wmic.exe") delete
wmic process where (commandline like "%%org.apache.flume.node.Application%%" and not name="wmic.exe") delete
wmic process where (commandline like "%%kafka.Kafka%%" and not name="wmic.exe") delete
wmic process where (commandline like "%%zookeeper%%" and not name="wmic.exe") delete

你可能感兴趣的:(笔记,windows)