Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill process that may not exist on prebuild step in 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
)

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

like image 515
Eugene Maksimov Avatar asked Apr 01 '13 17:04

Eugene Maksimov


People also ask

How do I kill a process in Visual Studio?

In the task Runner Explorer window, you'll see a tab that has "(running)" in it's title. Click the X to close the tab, and visual studio will ask you if you want to terminate the task. If you chose to terminate it, the tab will disappear. Show activity on this post.

How do I kill a process in Visual Studio Task Manager?

In Task Manager, if you go to the applications tab, you can right click on the instance you want to kill based on the name, then click on "Go to process". It should select the process you want to kill. Show activity on this post.


1 Answers

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

  taskkill /f /fi "pid gt 0" /im xdesproc.exe
like image 69
Hans Passant Avatar answered Oct 16 '22 12:10

Hans Passant