Thursday, April 19, 2007

Windows Services application

Create a Normal C# windows Services application :
-----------------------------------------------------

After creating the application


add the installer to it...


To add installers to your service application :
-----------------------------------------------

In Solution Explorer, access Design view for the service for which you want to add an installation component.
Click anywhere within the designer's surface.
In the Description area of the Properties window, click the Add Installer link.
A new class, ProjectInstaller, and two installation components, ServiceProcessInstaller and ServiceInstaller, are added to your project, and property values for the service are copied to the components.

Click the ServiceInstaller component and verify that the value of the ServiceName property is set to the same value as the ServiceName property on the service itself.
To determine how your service will be started, click the ServiceInstaller component and set the StartType property to the appropriate value.Value Result
Manual The service must be manually started after installation. For more information, see Starting Services.
Automatic The service will start by itself whenever the computer reboots.
Disabled The service cannot be started.

To determine the security context in which your service will run, click the ServiceProcessInstaller component and set the appropriate property values. For more information, see Specifying the Security Context for Services.
Override any methods for which you need to perform custom processing. For more information, see Overriding Default Methods on Installation Components.
Perform steps 1 through 6 for each additional service in your project.
Note For each additional service in your project, you must add an additional ServiceInstaller component to the project's ProjectInstaller class. The ServiceProcessInstaller component added in step three works with all of the individual service installers in the project.
Create your setup project and custom action to deploy and install your service. For more information on setup projects, see Setup Projects. For more information on custom actions, see Walkthrough: Creating a Custom Action.


After the installer is added to our windows services,

I selected the ServiceProcessInstaller1 control's properties...

I modified the "Account" property of the serviceProcessInstaller1 as "LocalService".


ServerInstaller1 control have the "name" property which holds the name of the service listed in "Administrative tools ".



//and then run the service from the


InstallUtil :
-----------------

In command prompt


installutil windowsServices1.exe //Install the services in Service Control manager
installutil -u windowsServices1.exe // Uninstall the services in Service control manager...










Starting the Service Manually :
----------------------------------

There are several ways you can start a service that has its StartType process set to Manual — from Server Explorer, from the Windows Services Control Manager, or from code. It is important to note that not all of these methods actually start the service in the context of the Services Control Manager; the Server Explorer and programmatic methods of starting the service actually manipulate the controller.

To manually start a service from Server Explorer

In Server Explorer, add the server you want if it is not already listed. For more information, see Accessing and Initializing Server Explorer.
Note The Servers node of the Server Explorer is not available in the Standard Edition of Visual Basic and Visual C# .NET. For more information, see Visual Basic Standard Edition Features or Visual C# Standard Edition Features.
Expand the Services node, and then locate the service you want to start.
Right-click the name of the service, and click Start.
To manually start a service from Services Control Manager

Open the Services Control Manager by doing one of the following:
In Windows 2000 Professional, right-click My Computer on the desktop, and then click Manage. In the dialog box that appears, expand the Services and Applications node.
- or -

In Windows 2000 Server, click Start, point to Programs, click Administrative Tools, and then click Services.
Note In Windows NT version 4.0, you can open this dialog box from Control Panel.
You should now see your service listed in the Services section of the window.

Select your service in the list, right-click it, and then click Start.



To See more about Windows Services :
--------------------------------------
www.c-sharpcorner.com
http://www.c-sharpcorner.com/UploadFile/prvn_131971/BirthdayWishScheduler02022006012557AM/BirthdayWishScheduler.aspx

No comments: