DOS下使用WMIC命令,按照进程启动命令搜索进程ID
wmic命令行,是DOS下,一个非常强大的工具。
在DOS下,不使用wmic行,想要对进程进行一些比较复杂的操作,非常难以完成。
比如,如下任务,使用wmic命令,查询指定命令行启动的ffmpeg进程的ID号:
wmic process where “name=‘ffmpeg.exe’ and CommandLine like ‘%rtmp://10.235.131.150:1935/myapp/2%’” list INSTANCE
可以查找进程名为ffmpeg.exe,并且启动该进程的命令中,包含"rtmp://10.235.131.150:1935/myapp/2"字符串的特定进程,来获取其进程名
wmic process where “name=‘ffmpeg.exe’ and CommandLine like ‘%rtmp://10.235.131.150:1935/myapp/2%’” get Caption,CommandLine
查找指定的进程名,并显示Caption、CommandLine这两列
终止查找到的进程:
wmic process where “name=‘ffmpeg.exe’ and CommandLine like ‘%rtmp://192.168.1.128:1935/myapp/zhanting%’” call terminate