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.
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.
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:
From the Windows Start menu, run the Registry Editor (regedit.exe).
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
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.