Single .EXE acting as Service or Application -- Possible?

L

Lee Schipper

Is it possible to create a single .EXE that can be launched either as a
service or as a standard application (with configuration screens, status
windows, etc...)?

I have an existing program that currently runs as a standard application.
When the user runs the app they can monitor its progress, review error logs,
and change configuration settings. I need to convert this program to run as
a service, but would like the user to retain the option of running it as a
standalone, interactive, application.

In a perfect world, the .EXE would be installed as a service, but if the
user clicks on the .EXE (or a shortcut) it would start in an interactive
mode.

Thanks!
Lee
 
J

Jay B. Harlow [MVP - Outlook]

Lee,
I would consider having a parameter to the exe.

If the parameter is set, start as a service, if the parameter is not given,
start as a normal executable. Basically in your Sub Main, if the parameter
is given do the ServiceBase.Run else do Application.Run.

Ideally however I would create two executables. One for the UI that the user
would use, and a second for the service...

Hope this helps
Jay
 
T

Trev Hunter

Lee,

In addition to what Jay mentioned about creating a separate executable for
the user interface, you could use remoting to communicate between the user
interface and service when you set configuration settings.

HTH,

Trev.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top