I have a program that can be installed and started as service, or can be started from SYSTEM account using the 'at' command. I need to find a way to know if the executable was started as service or from SYSTEM account, so I could know if I need to call ServiceBase.Run or perform other work at the executable entry point (Main function).
Environment.UserInteractive
is false in both situations.
WindowsIdentity.GetCurrent().IsSystem
is true in both situations.
I'd like not to pass any command line arguments to solve this.
Entry point's ReflectedType.BaseType.FullName
doesn't work either.