Hello,
I'm trying to write an executable that is both a Windows Service and a
utility for managing that service from the command line. The question is,
how can I determine if 'main' in my J# (or C#) code is being called by the
service manager or from the command line?
Currently I'm differentiating these two cases by requiring the CLI usage to
specify some arguments, as I have yet to see 'main' (vs. 'OnStart') receive
any arguments from the service manager. However, I would like to be able to
specify no arguments from the CLI as well and yet still detect this as CLI
usage. Is there some class method I can call to differentiate these two
scenarios?
By the way, I also noticed that contrary to the docs for ServiceBase.Run(),
it does NOT throw an exception when invoked from a command line program but
rather pops up a GUI error message and then simply returns, so the caller
presumably has no way to know that it failed.
Thanks!
Dan S.
|