bat判断进程是否存在

setlocal enabledelayedexpansion
@echo off
cd /d D:work ool ginx-1.13.7

set hasit=no
for /F "tokens=1*" %%a in ('tasklist /nh /fi "imagename eq nginx.exe"') do if %%a == nginx.exe set hasit=yes
if %hasit% == yes goto end
start nginx.exe
:end
set hasit=

nginx.exe -s reload

echo "结束进程"
TASKKILL /F /IM node.exe

echo "启动node"
cd /d D:workIdel m_edc5.0

cnpm run deploy

原文地址:https://www.cnblogs.com/sprinng/p/8193441.html