Can one EXE double as Windows Forms app and as Windows Service?

G

Guest

I have a Windows service application with a public class that inherits from
System.ServiceProcess.ServiceBase

Is it possible to modify this application so that it still is a Windows
service but on the other hand can be started just as if it were a standard
Windows Forms application (e.g. by double clicking the .exe file)?

Background:
I would like to deliver a .exe file to the user who then double clicks it.
The application then offers a UI with options to install itself as service.
For diagnostic purposes it also would be nice to tell the user "Shut down
that service and then double click the .exe" to get an application with UI.

Thanks for any ideas,
Guido
 
K

Kevin Spencer

Write a business class that performs the work of the service. You can host
it in any type of user interface or API.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
To a tea you esteem
a hurting back as a wallet.
 
Y

Yuan Ren[MSFT]

Hi Guido,

Thanks for your post!

From your description, my understanding is you want create your own winform
application to install and manage the windows services application. If I
have misunderstood anything, please feel you free to let me know.

As far as I know, if you want to install the windows services application
programmatically, there are two ways to approach this. One is writing the
installation script; another is using Win32 native API. The following
articles demonstrate how to use these two ways:

¡°Installing a Service Programmatically¡±:
http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatic
ally.asp

¡°Install a Service using a Script¡±:
http://www.codeproject.com/dotnet/ScriptedServiceInstall.asp?df=100&forumid=
115279&exp=0&select=974615

To manage the windows services application, there is an appropriate sample
from the Codeproject site:
http://www.codeproject.com/csharp/winservicemanage.asp

I hope the information will be helpful!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
updated on February 14, 2006. Please complete a re-registration process
by entering the secure code mmpng06 when prompted. Once you have
entered the secure code mmpng06, you will be able to update your profile
and access the partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 

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