Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

How different is the command window from a normal window?

share|improve this question
    
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
    

3 Answers 3

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.

share|improve this answer
    
what certain utilities ? Alt-F4 close almost all the windows in NT Systems, then why command prompt is an exception ? –  Peeyush Sep 3 '12 at 5:19
    
Applications before Windows NT in DOS. I remember one game where Alt+F4 brought up the save menu for a game (Wing Commander Armada I believe). Since this is designed to Emulate(or display) DOS it must accept this key combination and not close so these apps can receive the command. –  Jeff F. Sep 4 '12 at 18:12
    
oh.. Okay... So Microsoft must be still using that combination for some functionality, otherwise they must have provided support by now. –  Peeyush Sep 5 '12 at 5:29

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
share|improve this answer

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.

share|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
1  
As you can see with iglvzx’s answer, consoles do indeed close in response to WM_CLOSE. –  Synetech Mar 20 '12 at 17:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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