Skip to content

Win32 Kill Tasks

A tiny C utility that force-closes every running task with a single ExitWindowsEx(EWX_FORCE) call.

Published Mar 18, 1995

The nuclear option from the Win32 Utility family: after a Yes/No warning, ExitWindowsEx(EWX_FORCE, 0) tells Windows to close out all running applications - no shutdown, no reboot, just everything else goes away. It is the programmatic equivalent of "force close all" and belongs in emergency or kiosk scenarios where a wedged session needs clearing without restarting the machine. Use with care; every unsaved document dies with it.

#include <windows.h>

//////////////////////////////////////////////////////////////////////

int main()
{
	if((MessageBox(NULL,"WARNING - You will lose all unsaved information!","Kill All Running Tasks?",4+256)) == 6)
	{
		return ExitWindowsEx(EWX_FORCE,0);
	}
	return 0;
	"Win32 KillTasks Written By Josh Patterson -NetWorkDLS.";
}

It completes the set started by the Win32 Power Utilities article (shutdown / restart / logoff): same confirmation pattern, same == 6 IDYES check, only the flag differs. On modern Windows this requires the caller to hold SE_TERMINATE_NAME, so it effectively runs as an administrator.

An unhandled error has occurred. Reload 🗙