10

When we kill a process in Windows with Task Manager End Process command, will the process still return an exit code? And if so, what exit code it returns? Thanks

2 Answers 2

12

In general, a process is terminated using TerminateProcess. The exit code is passed as a parameter to this method.

In the case of the task manager, the exit code is set to 1, but I don't know if it's documented anywhere.

Sign up to request clarification or add additional context in comments.

Comments

0

Yes, it will return non-zero return code which will be wrapped in %ERRORLEVEL% variable.

3 Comments

This depends on the application, there is no standard value AFAIK
I still don't get it why did somebody downvote this answer :(
@Armen: nevermind :) IMHO, you shoudn't rely on exit code to detect that application has been terminated or killed (unless this is your own application and you provide special exit code for this case) as ERROR_INVALID_FUNCTION (i.e. 1) may be returned in bunch of other situations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.