Announcement

Collapse
No announcement yet.

Installing and running the .exe as a service

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Installing and running the .exe as a service

    Now I have my .ex. Can I install and run it as a service?

  • #2
    Search 'service', message subject, all forums, all dates ==> 113 hits. Many directly address your question.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Virginio,

      As Michael pointed out, there are a number of examples of how to do this. I would just like to toss out a bit of caution here though. Unless you are pretty sure your app is "service compatible", be very careful. You won't likely mess up your computer, but you can make it difficult to get back to normal.

      Not just any program should run as a service. It needs to meet some pretty strict requirements. The least of which is that it should have no interaction with the host computer. Yes, there are exceptions, and yes it can be done safely, but its not easy to create a service that interacts with the desktop...they weren't made for that.

      If you need interaction, you're better off writing a 'control program' that talks to the user and your service 'from the middle'. Lots of ways to do that too, some examples are on the forum.

      Bottom line, 'service apps' and 'regular apps' are not the same and they can't be mixed and matched without some fore-thought.
      Software makes Hardware Happen

      Comment


      • #4
        For a user interactive desktop program, you can make a link in
        Start/All Programs/Startup
        to have it start at log-in/bootup.
        Dale

        Comment


        • #5
          i would like to do the service thing too, but i took the easy way.
          i wrote a program with pbwin and it starts off with a hidden dialog.
          the program can be killed or stopped with the task manager.
          i gave the dialog a name of something that looks like part of the system, because i wanted it to run in a harmless way but also be concealed in some way.

          i have the program start as a runonce program then when the program starts, it sleeps for a certain amount of time after the computer boots.

          i wrote a program that can make any dialog unhidden and that is what i use if i want to bring the dialog to view or any other program i want running in this fashion.

          if you decide to the service thing, please display some code so i can learn too.
          paul
          p purvis

          Comment


          • #6
            There's a very nice Windows Service Boilerplate in the Source Code section of the forum, which includes routines to register/deregister (it's really all about "registering" an EXE as a service to the Service Manager) an EXE as a service.

            Problem is: Your EXE needs to be designed to run as a service. It's a lot different than a typical desktop app.

            Only got the URL to the old UBB posting, but that still works: http://www.powerbasic.com/support/fo...ML/003954.html

            Have used that myself and it worked flawlessly.

            Comment


            • #7
              Have used that myself and it worked flawlessly.
              Ditto.

              Paul,

              I understand your reasoning, but if I purchased a program that did this, I'd be very upset, and depending on where you live, and what the program did, and how your license agreements worked, you could be in for other legal issues too.

              It appears to the average user (at least the not-so-average) that you are trying to hide something this way. Its so un-standard that the only logical conclusion is that it has a malicious intent, otherwise, why go to such extremes? If it were a program that should always be running regardless of whether the user is logged in or not (the #1 consideration for using a service), then it should be run as a service. If its not, then (a) you're either doing something maliciously, or you're not a very good programmer (THIS IS NOT what I'm saying, its how it usually APPEARS to people when they see such non-standard methods).

              I've purchased a number of programs where the publishers admitted it would be best to run as a service, but quite frankly, they did not know how to do that. Instead, they included a widely available, free program called 'invoker' which wrapped the service characteristics around any program and allowed you to run (just about) any program as a service. Not elegant, and it failed as often as it worked, but at least they were up front and admitted that their program would be best as a service but they didn't know how to do that.

              If I came across a program doing what you do, and I would spot it pretty quickly, as would any decent anti-intrusion software, I'd be very, very, very upset.

              Of course, if these are just for yourself, or a few close friends, then no big deal, but its a terrible way to do things for wide-spread use, IMO.
              Software makes Hardware Happen

              Comment


              • #8
                >Not elegant, and it failed as often as it worked,

                In your case Joe, did that represent a significant or only a minor improvement in your "success ratio?"
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  One other thought I had.

                  Beyond the 'how', the biggest question you should as is why.

                  Quite frankly, there aren't a lot of programs that should run as a service, so you'd better have a good reason for doing so.

                  The first question is, "what happens if the user logs off, or, in the same vein, boots the PC but doesn't log in.

                  Will your program be "missed"? The only "Yes" answer to that question is if your program is serving other computers. For example, a Web server needs to be running regardless of whether someone is logged in on the local PC or not. The same with an SQL server, or Email server, etc. You don't want to have someone ctrl/alt/del and log in every time the PC reboots, and you surely don't want these automatically logging themselves in.

                  So if your program only 'services' the person physically using it, you need a good reason why it has to be a service. If another program depends on this one to run, that can be good case perhaps. However, just because you think it should always be running whenever the computer is on, is not a good reason to run as a service. The owner of the PC should always have the say in how/when/where a program runs on their PC. If the reason for it being a service is legit, few, if any, will argue, but do run as a service because you think it should, or it looks "cool", is a bad idea.

                  Also, lots of people get the idea that a "tray app" (a program controlled from the system tray) is, or has to be, a service. These two are not equal. In fact, you'd never have enough room for an icon for every service that Windows itself runs! A tray app can be, but often is not, a service.

                  So think twice, perhaps three times, before deciding that you need to run your program as a service. There are really very few apps that should, and even less that need to be.
                  Software makes Hardware Happen

                  Comment


                  • #10
                    Originally posted by Michael Mattias View Post
                    >Not elegant, and it failed as often as it worked,

                    In your case Joe, did that represent a significant or only a minor improvement in your "success ratio?"
                    Not sure about your question Mike, but the one time that I remember this being an issue, was with a Web calendar application that I purchased. In essence, it was a stand alone web server. I could create a URL for anyone that they could use as a button link on their web site to have a full-blown, interactive calendar. It was necessary for me to have this application running at all times, just like a "normal" web server.

                    The Invoker program actually worked perfectly on this program. The main reason for its success was the fact that the calendar program didn't need any interaction once it was started. All the calendar configuration, including my set ups as the admin (create new calendars, delete old ones, etc) was done through a web browser. I didn't need to actually 'use' the program on that computer at all.

                    I still have 'invoker' in my toolbox, but I can't remember the last time I thought to use it.
                    Software makes Hardware Happen

                    Comment


                    • #11
                      I made a Service template I believe was posted both here and posted a version over on Paul's forum that works pretty well with FireFly. From experience though you really want to make it not interact with the desktop, although in some cases commands like PB's TCP/UDP want a Window and you have to at least make a message class window. I never could get the PC to shutdown the app gracefully when a window interacted and the PC shutdown. Usually there was a beep or memory error message and/or an event log error. It seems on shutdown the interactive window gets the message to shutdown too and closes at the same time as the service, so lots of things get in an unknown state. I have some apps that require interaction though and need to be a service since the machines aren't always logged on. Still trying to tweak it, but it isn't perfect yet.
                      sigpic
                      Mobile Solutions
                      Sys Analyst and Development

                      Comment


                      • #12
                        Let explain what I'm trying to do and how I need the app. to work (I have it done in VB6):

                        It is an interface for a PBX which recives the CDR's from the PBX and store them in a SQL server (local or on the network).

                        the user at the first run have to setup the com port settings (interact with the app throug a window)

                        The user may need to open a built in monitor to debug the serial comms

                        The computer is supposed to be running unattended, so the app needs to run without a login

                        when the app (service) starts, puts an icon in the task bar, from where the settings or the monitor can be called.


                        Not in the proper order, but this is what I need my app to be able to do.

                        Comment


                        • #13
                          >when the app (service) starts, puts an icon in the task bar

                          1)There is no taskbar when the service executes.

                          2) A service is supposed to be window-less, no one can respond..
                          hellobasic

                          Comment


                          • #14
                            "It is an interface for a PBX which recives the CDR's from the PBX and store them in a SQL server (local or on the network)."

                            This job I am familiar with (I maintain one Nortel Option 61C and two 11Cs), though I didn't have to write the Call Detail Recording (CDR) software because OTM and PhonEx where purchased with the PBXs.

                            You need at least two programs. One service that communicates with PBX and stores data. And a second with user interface that is for editing the service's setup.

                            I haven't looked since forum upgrade, but there should be two service program examples in PB's download section. Have you seen them?
                            Dale

                            Comment


                            • #15
                              My Service I made does something similar. To show in the tray is only possible when logged in, and by then your app already started, so you will want to Register to get the message of when the taskbar is created to put/re-put your icon there (This will restore the icon to the tray if Explorer crashes and you lose your icon too). You will need to interact with the desktop for this though. A better way would be two files, one a service and one the tray app that communicates with the service.
                              sigpic
                              Mobile Solutions
                              Sys Analyst and Development

                              Comment


                              • #16
                                Dale, I also work with M1. I have a few (ten or so Option 11 and a CS1000S)

                                The interface is intended to be not only for the M1, but for other makes. Is intended to be a comercial product. I have a version I made in VB6 for Alcatel, and it is working (not as a service).

                                The setup is a form started from the monitor. The settings will be stored in the DataBase too or in the registry. Didn't decide yet.

                                Roger, I understand that the icon only shows up when logged in. But as long the app is running it will be responding to the received data event and process it.

                                The thing is: is it possible to have the service running, doing the data processing, and when logged in allow to monitor and change the port settings?

                                Thank You all

                                Comment


                                • #17
                                  As a different take/approach to a similar problem (a service running and the need to check status / configure it), you could consider implementing all the UI in the service as a minimal web server.
                                  So one have just to open a browser to http://localhost:yourport, maybe even from another machine.

                                  Just a tought.

                                  Bye!
                                  -- The universe tends toward maximum irony. Don't push it.

                                  File Extension Seeker - Metasearch engine for file extensions / file types
                                  Online TrID file identifier | TrIDLib - Identify thousands of file formats

                                  Comment


                                  • #18
                                    Originally posted by Dale Yarker View Post
                                    I haven't looked since forum upgrade, but there should be two service program examples in PB's download section. Have you seen them?
                                    Didn't find anything. Do you have an example?

                                    Comment


                                    • #19
                                      Check this: http://www.powerbasic.com/support/do...es/ServeMe.zip

                                      It's a well documented example for a minimal Windows service, written in 2004 by Tom Hanlin.

                                      Bye!
                                      Last edited by Marco Pontello; 16 Mar 2008, 09:00 AM.
                                      -- The universe tends toward maximum irony. Don't push it.

                                      File Extension Seeker - Metasearch engine for file extensions / file types
                                      Online TrID file identifier | TrIDLib - Identify thousands of file formats

                                      Comment


                                      • #20
                                        Marco found one of the two I was thinking of. Here is another:



                                        and it has a control panel. I don't think it is the second one I remember, but it looks better (after only quick scan of source code).

                                        Good luck with project.
                                        Dale

                                        Comment

                                        Working...
                                        X