I'm running a Visual Studio post build event that shuts down IIS if it's still running after compilation:

taskkill /f /im w3wp.exe

The following works perfectly if IIS is still running, but throws an error if it has already stopped:

Error 1 The process "w3wp.exe" not found. xxx\EXEC

Is there a way to tell taskkill to ignore the problem if it can't find a matching running process?

link|improve this question
feedback

1 Answer

up vote 5 down vote accepted

Instead of running one command, would running a small batch file work instead?

tasklist /FI "IMAGENAME eq w3wp.exe" 2>NUL | find /I /N "w3wp.exe">NUL
if "%ERRORLEVEL%"=="0" taskkill /f /im w3wp.exe
link|improve this answer
perfect, thanks! – Luk Jan 13 '11 at 14:38
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.