How to kill process that may not exist on prebuild step in Visual studio?

跟風遠走 提交于 2019-11-29 17:10:33

问题


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:


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

  taskkill /f /fi "pid gt 0" /im xdesproc.exe


来源:https://stackoverflow.com/questions/15748355/how-to-kill-process-that-may-not-exist-on-prebuild-step-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!