Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. These features make services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer. You can also run services in the security context of a specific user account that is different from the logged-on user or the default computer account.
Note:Windows Services are not available on older machines running Windows 95,98 Or ME , Windows 2000, NT, XP, + all have the ability however (not that this should be an issue, Just letting you know that windows services
will not be Multi OS, only NT 4.0 and --->)
If you want your application to be a running process in the background, Windows Services is the best approach
Creating a Windows Service in VB.NET
Before Vb.net Performing this task was hard or limited to the C++ Guru's because it required System Level Processes and Procedures But with the ,net framework and VB.net this task is 1000 times easier and more achievable.
Note: The .net Framework will help us install and control Windows Service.
As always, Open Vb.net and follow along, It is the only way you will learn anything.
(Double Click Timer1)(Timer_Tick Event)
' This will be executed every 20 seconds
[php]
'Create a New Instance for a Log
Dim ML As New EventLog()
'Check if a Event Log Exists
If Not ML.SourceExists("Whatever You Called Your Application") Then
' Create a Log
ML.CreateEventSource("Your Application", "Myservice Log")
End If
ML.Source = "What you called your application (Service)"
' Write a Log
ML.WriteEntry("Service Log", "Log On For " & _
CStr(TimeOfDay), EventLogEntryType******rmation)
[/php]
In this part of the code
[php]
Protected Overrides Sub OnStart(ByVal args() As String)
End Sub
[/php]
Enable the timer
[php]
Timer1.Enabled = True
[/php]
And on service stop
[php]
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
End Sub
[/php]
Disable the timer
[php]
Timer1.enabled = false
[/php]
Now create your application/Service to do whatever it is you would like it to, and your good to go