Disable pause after execution 2

z l 20 Reputation points
2025-01-09T19:09:28.4033333+00:00

What happened to the first post where I asked this question?

Why are there still these puzzle verifications when posting?

--

It's been asked for years, and I was wondering if something has finally been done about it.

I'd like after an execution of a c++ console app without debugging (ctrl+f5) not to be required to press a key to continue.

Why? Since I also execute from a shortcut, and then I have a behavior when sometimes it waits and sometimes it doesn't, and the inconsistency throws me off.

Why not run with debugging (f5)? Since then, when I want to go over the code while it's running, I need to detach the debugger.

Since you haven't changed it in years, and you probably never will, can you at least explain the reason for this behavior? One would have thought that if a debugger is attached, then VS is watching, and then pauses after execution, and not the other way around.


A related issue. When executing without debugging, it seems that VS is still "watching." I have this issue:

https://drive.google.com/file/d/1Q1L2z6d7mYIwVu_oIpnKtuK2fd6hN-5z/view?pli=1

Can you explain how VS is still watching without being attached?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,399 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,837 questions
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 32,531 Reputation points Microsoft Vendor
    2025-01-10T08:26:56.6766667+00:00

    Hello @z l,

    Does changing the SubSystem(project property page > Configuration Properties > Linker > System > SubSystem) from Console (/SUBSYSTEM:CONSOLE) to Not Set make the Console window close automatically when you start your project without debugging(not a workaround, but maybe mitigate the issue in some specific scenarios)?

    About the "VS is still watching" issue, I'm not sure if this appears in specific situations. If you could share detailed reproducible steps for replicating this issue, it will be useful for checking further.

    Kind Regards,

    Tianyu

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Michael Taylor 56,541 Reputation points
    2025-01-09T19:31:31.46+00:00

    The behavioral change for console apps was made because if you run a console app without any breakpoints then any output displayed at the end of the program will go away before you can read it, if applicable. Since this is a common thing the console window behavior was modified to pause at the end so you can review any final output from the program before closing it yourself. Alternatively you just ignore the window and you can start debugging again and it'll auto-close the last window, effectively.

    As you mentioned, the only time this might be problematic is if you're starting the debugger and another program is waiting for the program to terminate. The easiest thing to do is to just close the window since this is when the app actually terminates. But if you don't want this behavior and are OK disabling it across the board then go to Tools \ Options -> Debugging \ General. Find the setting called Automatically close the console window... and check the box. You'll be back to the old approach.

    User's image

    I'm not aware of a per-project option for this.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.