如何杀死可能不存在prebuild步骤在Visual studio中的过程? [英] How to kill process that may not exist on prebuild step in Visual studio?

查看:206
本文介绍了如何杀死可能不存在prebuild步骤在Visual studio中的过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是如果这个过程不存在,构建失败。我尝试写这样

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
)

但是ERRORLEVEL等于

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

推荐答案

您可以对PID使用条件测试,以避免这种情况发生。如果XDesProc.exe未运行, :

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

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

这篇关于如何杀死可能不存在prebuild步骤在Visual studio中的过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆