问题是如果这个进程不存在,构建就会失败。我试图写出像这样的东西
tasklist /nh /fi "imagename eq XDesProc.exe" | find /i "XDesProc.exe" && (
TASKKILL /F /IM "XDesProc.exe"
) || (
echo XAML designer is not running
)
但是ERRORLEVEL也等于1,如果XDesProc.exe没有运行,则构建失败。
问题是如果这个进程不存在,构建就会失败。我试图写出像这样的东西
tasklist /nh /fi "imagename eq XDesProc.exe" | find /i "XDesProc.exe" && (
TASKKILL /F /IM "XDesProc.exe"
) || (
echo XAML designer is not running
)
但是ERRORLEVEL也等于1,如果XDesProc.exe没有运行,则构建失败。
您可以使用 PID 的条件测试来避免这种情况:
taskkill /f /fi "pid gt 0" /im xdesproc.exe