This article applies as of PRTG 24

When creating a C# console application that returns values via exit codes, encountered issue where PRTG Network Monitor misinterprets these exit codes. Using return in the Main method does not guarantee the correct exit code is recognized by PRTG.



To ensure proper exit code interpretation, use 

Environment.Exit(ret)

 in the `Main` method. This explicitly sets the exit code, ensuring that PRTG correctly identifies the program's status. Implementing this method allows the application to reliably communicate success or failure to external systems like PRTG Network Monitor.


Disclaimer:
The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.