Search code examples
exceptionconsole-applicationscheduled-taskswindows-server-2012-r2windows-task-scheduler

Task scheduler console application shows just in time debugger on exception preventing program to run again


I have a console application that runs every 5 minutes in Windows Task Scheduler. The program doesn't run again if the program is still running after 5 minutes, so only one instance at a time.

However, when an exception occurs, the just in time debugger appears and doesn't go away, preventing the application from running again.

Is there a way to prevent this? I want the JIT debugger to not appear so the application is finished and it will run again on the next try.


Solution

  • One question would be why the program is ending with an exception? Wouldn't it be better to have some redirection into file if you don't need the exception(s).

    I would personally disable JIT debugger at registry. From the visual studio docs, when VS is not installed at the computer, which is probably the case.

    Disable Just-In-Time debugging from the Windows registry

    Just-In-Time debugging may still be enabled even if Visual Studio is no longer installed on your computer. If Visual Studio is no longer installed, you can disable Just-In-Time debugging by editing the Windows registry.

    To disable Just-In-Time debugging by editing the registry:

    1. From the Windows Start menu, run the Registry Editor (regedit.exe).

    2. In the Registry Editor window, locate and delete the following registry entries:

      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger
      
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
      
    3. If your computer is running a 64-bit operating system, also delete the following registry entries:

      HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\DbgManagedDebugger
      
      HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
      

    Make sure not to delete or change any other registry keys.