This post was imported from an old blog archive, and predates the creation of

This is a useful function to close a program based on a windows caption, this should work for any top-level window. Paste all this into a standard module, save it. Then call CloseApp("Notepad") or whatever the name of the window is, it’s nice & simple and should close the program instantly.

This requires Windows 2000 plus, for older versions of Windows a different method is required, that isn’t covered here, seeing as Windows 2000 and better require special privileges to forcefully close a program.

(Note: your user account must have ‘Debug’ privileges for this code to work, this means if you aren’t an administrator or a member of the ‘Debuggers’ group, this code will fail to execute).

The Code: