In windows, alt+F4 does not close cmd (As in: WindowsKey+R, cmd, Enter)

How different is the command window from a normal window?

link|improve this question

62% accept rate
There are some third-party hotkey handling programs out there. Some should be able to intercept Alt-F4 only for the relevant command-prompt windows, and use an alternative shutdown (e.g. type "exit", or click the close button, or use the system menu "close" option). Obviously, you should be aware of the possible downside (see Jeffs answer). Sorry, I can't make a recommendation. – Steve314 Dec 6 '11 at 23:50
feedback

3 Answers

The command window uses those key combination for varies applications within the dos emulating window. If Alt-F4 closed the window, it may be impossible to use certain utilities. If you want a keyboard only fix just type exit to quit.

link|improve this answer
feedback

Alt+F4 sends the program with focus the WM_CLOSE message.

So, the cmd program is either intentionally configured to ignore WM_CLOSE messages, or possibly doesn't process any messages at all.

link|improve this answer
This does not entirely apply to Win32 Console windows - they're owned by conhost (earlier - by csrss), and console applications handle it differently. – grawity Jan 20 '11 at 14:44
@grawity, duly noted, thanks. But it sounds like that could be the start of the real answer to the question. – DMA57361 Jan 20 '11 at 21:13
@grawity - I thought within windows, there was still a WM_CLOSE message handled as part of the console program. Not that it makes much difference, though - this is an answer for programmers working on the source of cmd.exe, not for users curious about the design rationale. – Steve314 Dec 6 '11 at 23:45
As you can see with iglvzx’s answer, consoles do indeed close in response to WM_CLOSE. – Synetech Mar 20 at 17:54
feedback

On the other hand, if you are looking to have Alt+F4 close the console window, you can use the following AutoHotkey script:

#IfWinActive, ahk_class ConsoleWindowClass
    !F4::WinClose, A

#IfWinActive
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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