Overnight processes

  • Thread starter Carlos J. Quintero [VB MVP]
  • Start date
C

Carlos J. Quintero [VB MVP]

Hi Andy,

I don´t know about the icon problem but processes like your program are
better implemented as services, not requiring a user logged on, and the
service can be configured to run on Windows startup. Once your program is a
service, there are 3rd party monitoring tools used typically by the the
people managing servers, etc. to monitor and restart Windows services (my
company uses one of them).

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
 
A

Andy Baker

Our VB.NET 2003 application requires several processes to run overnight. I
have written a program to perform these processes with a simple user
interface to allow the user to switch various options on/off, and using the
code from VB.NET programmer's cookbook (NotifyIcon) have it running in the
system tray. When windows xp is started, the overnight routines program
starts, and the icon appears in the system tray. I then use a timer to
perform the routines at the appropriate time.
It is important that this program is always running, so I need a way of
constantly monitoring the running processes, and if the overnight program is
not running, restart it. I have created a windows service that starts when
windows starts, and whose sole purpose is to check at various intervals to
see if the program is running. This works successfully except for the fact
that when the service restarts the application, the icon doesn't appear in
the system tray, although it is running. The code in the service is

Dim strHousekeepingFilename as String = "C:\Overnight.exe"
Processes = System.Diagnostics.Process.GetProcessesByName("Overnight")
If Processes.Length = 0 then
Dim HKProcess as New System.Diagnostics.Process
HKProcess.StartInfo.Filename = strHousekeepingFilename
HKProcess.Start
End if

How can I get the icon to appear in the system tray, or is there a better
way of ensuring that the program is always running? Thanks in advance.

Andy Baker
 
A

Andy Baker

Hi Carlos

Thanks for the quick reply. I thought of implementing the whole thing as a
service, but it requires a user interface of sorts, so the user can choose
which options to run overnight, and also to be able to force the routine
during the day in case it has not run overnight for some reason. Is there a
way of adding a form to a service?

Andy Baker
 
C

Carlos J. Quintero [VB MVP]

Hi Andy,

Yes:

- Services can have too an user interface in the notifications area, such as
SQL Server or most antivirus.

- Or you can even create an standalone executable to configure your service
that can set options, start or shutdown it, etc . See the MSDN docs about
the ServiceController class:
http://msdn2.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
 
A

Andy Baker

Hi Carlos

Thanks for that. I think that I'll get the routines working in the
executable that I have at the moment, and then put the whole thing in the
service. To add the user interface to the service project, is it as simple
as adding a form and setting the startup object for the project?

Andy Baker
 

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