Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 14 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
share|improve this answer
1  
perfect, thanks! –  Luk Jan 13 '11 at 14:38

The solution I found to this was to run

START taskkill /f /im w3wp.exe

It returns a success from the START command, and any error thrown by TASKKILL is thrown in the new console window

share|improve this answer

Or, this will just return an info message if not found:

taskkill /f /im w3wp.exe /fi "memusage gt 2"

Info from: here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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