How to kill process that may not exist on prebuild

2019-02-08 08:05发布

Problem is if this process doesn't exist, build fails. I try to write something like this

tasklist /nh /fi "imagename eq XDesProc.exe" | find /i "XDesProc.exe" && (
TASKKILL /F /IM "XDesProc.exe"
) || (
echo XAML designer is not running
)

But ERRORLEVEL is equal to 1 too and bild fails if XDesProc.exe is not running.

1条回答
beautiful°
2楼-- · 2019-02-08 08:44

You could use a conditional test on the PID to avoid this:

  taskkill /f /fi "pid gt 0" /im xdesproc.exe
查看更多
登录 后发表回答