Overnight processes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Baker

    #1

    Overnight processes

    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 strHousekeeping Filename as String = "C:\Overnight.e xe"
    Processes = System.Diagnost ics.Process.Get ProcessesByName ("Overnight" )
    If Processes.Lengt h = 0 then
    Dim HKProcess as New System.Diagnost ics.Process
    HKProcess.Start Info.Filename = strHousekeeping Filename
    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


  • Carlos J. Quintero [VB MVP]

    #2
    Re: Overnight processes

    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:
    MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.




    "Andy Baker" <abaker@NOSPAMv anputer.com> escribió en el mensaje
    news:4476e2b9$0 $18254$ed2619ec @ptn-nntp-reader01.plus.n et...[color=blue]
    > 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 strHousekeeping Filename as String = "C:\Overnight.e xe"
    > Processes = System.Diagnost ics.Process.Get ProcessesByName ("Overnight" )
    > If Processes.Lengt h = 0 then
    > Dim HKProcess as New System.Diagnost ics.Process
    > HKProcess.Start Info.Filename = strHousekeeping Filename
    > 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
    >
    >[/color]


    Comment

    • Andy Baker

      #3
      Re: Overnight processes

      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

      "Carlos J. Quintero [VB MVP]" <carlosq@NOSPAM sogecable.com> wrote in message
      news:urqgQcLgGH A.3364@TK2MSFTN GP05.phx.gbl...[color=blue]
      > 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
      >
      >
      >
      > "Andy Baker" <abaker@NOSPAMv anputer.com> escribió en el mensaje
      > news:4476e2b9$0 $18254$ed2619ec @ptn-nntp-reader01.plus.n et...[color=green]
      >> 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 strHousekeeping Filename as String = "C:\Overnight.e xe"
      >> Processes = System.Diagnost ics.Process.Get ProcessesByName ("Overnight" )
      >> If Processes.Lengt h = 0 then
      >> Dim HKProcess as New System.Diagnost ics.Process
      >> HKProcess.Start Info.Filename = strHousekeeping Filename
      >> 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
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Carlos J. Quintero [VB MVP]

        #4
        Re: Overnight processes

        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 ServiceControll er class:
        http://msdn2.microsoft.com/en-us/lib...ontroller.aspx

        --

        Best regards,

        Carlos J. Quintero

        MZ-Tools: Productivity add-ins for Visual Studio
        You can code, design and document much faster:
        MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.





        "Andy Baker" <abaker@NOSPAMv anputer.com> escribió en el mensaje
        news:447726e3$0 $574$ed2619ec@p tn-nntp-reader01.plus.n et...[color=blue]
        > 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[/color]


        Comment

        • Andy Baker

          #5
          Re: Overnight processes

          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

          "Carlos J. Quintero [VB MVP]" <carlosq@NOSPAM sogecable.com> wrote in message
          news:u2%23o6vvg GHA.1276@TK2MSF TNGP03.phx.gbl. ..[color=blue]
          > 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 ServiceControll er class:
          > http://msdn2.microsoft.com/en-us/lib...ontroller.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
          >
          >
          >
          >
          > "Andy Baker" <abaker@NOSPAMv anputer.com> escribió en el mensaje
          > news:447726e3$0 $574$ed2619ec@p tn-nntp-reader01.plus.n et...[color=green]
          >> 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[/color]
          >
          >[/color]


          Comment

          • Carlos J. Quintero [VB MVP]

            #6
            Re: Overnight processes

            Hi Andy,

            See these threads:


            --

            Best regards,

            Carlos J. Quintero

            MZ-Tools: Productivity add-ins for Visual Studio
            You can code, design and document much faster:
            MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.




            "Andy Baker" <abaker@NOSPAMv anputer.com> escribió en el mensaje
            news:447c0040$0 $2684$ed2619ec@ ptn-nntp-reader01.plus.n et...[color=blue]
            > 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
            >[/color]

            Comment

            Working...