What are the taskkill.exe exit codes?

Is there a list of known exit codes (errorlevel) for TaskKill.exe? Does this vary with the Windows version? I'm mostly concerned with Windows 7 and server 2008r2.


They probably correspond to standard Windows error codes. If you want to look up the verbose description, run NET HELPMSG nnnn, where nnnn is the exit code.

C:\>taskkill /im notepad.exe
SUCCESS: Sent termination signal to the process "notepad.exe" with PID 12144.

C:\>echo %errorlevel%
0

C:\>net helpmsg 0

The operation completed successfully.

All Win32 error codes are listed in the MSDN documentation:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx


If you're writing your script in PowerShell, why are you 'shelling out' to TASKKILL.EXE. Why not use the Stop-Process cmdlet? You're then in total control of any exception handling, Etc.