Once upon a time in C++-land I had a NT Service base class. Now that .NET has a fine base class, it's no longer needed. However, my old class had a nice feature that would run the app as a console app unless it was started by the SCM. It used the trick of having a command line parameter that the SCM was configured to send when it started the application. I'm wanting to add this kind of functionality to my .NET Windows Services. The command line option seems much harder with the new .NET Installer functionality so I thought I would Google Groups around for a more intrinsic solution.
Here's that less than 100% solution as Win32 code. It's SID code so it may be hard to P/Invoke.
As MS employee described
As C-code implemented
Here's a heuristic way