Facebook   Twitter    e-mail newsletter    YouTube    RSS Feed    Android App    iPhone and iPad App     BlackBerry App    


Page 1 of 2 1 2 LastLast
Results 1 to 15 of 23

Thread: Application Service Maker - Run any program as a service

  1. #1
    Grandmaster efitol's Avatar
    Join Date
    Oct 2005
    Location
    Neither nor
    Posts
    3,306

    Thumbs up Application Service Maker - Run any program as a service

    UPDATE 2013/03/23:

    Version 0.3 released.

    I've added some features which I've needed since the initial release. Maybe they'll be useful to others as well.

    - Duplication is now possible, i.e. you can run the same application more than once, like multiple "cmd" processes.
    - You can send arguments to an application.
    - You can set an application to close when you stop the service.
    - You can set the logging level to minimal (only logs errors) and verbose (logs pretty much everything that happens, for troubleshooting).

    All these features can be accessed by changing the config file "ApplicationService.exe.config" in "C:\Program Files\Blaq Entertainment\Application Service Maker" or wherever you elected to install to. If you don't need the new features then there's no need to alter your current settings as they're backward compatible.

    PLEASE MAKE A BACKUP OF YOUR CURRENT CONFIG FILE BEFORE UNINSTALLING OR UPDATING!

    The new format for defining applications is

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
                <section name="ApplicationService.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
            </sectionGroup>
        </configSections>
        <userSettings>
            <ApplicationService.Settings>
                <setting name="TimerIntervalMinutes" serializeAs="String">
                    <value>20</value>
                </setting>
                <setting name="ApplicationList" serializeAs="String">
                    <value>{app;path;can_duplicate;args;close_on_exit}</value>
                </setting>
                <setting name="LoggingMode" serializeAs="String">
                    <value>M</value>
                </setting>
            </ApplicationService.Settings>
        </userSettings>
    </configuration>
    where
    app is the name of the application to run (e.g. python)
    path is the path to the application (e.g. C:\Python27\python.exe)
    can_duplicate is either "Y" or "N" to indicate if the service can run the application even if it was already started.
    arguments is whatever arguments you want to send to the application (e.g. "C:\Program Files\SickBeard\SickBeard.py")
    close_on_exit is either "Y" or "N" to indicate if the service should close the application when the service is stopped

    You can also see the "LoggingMode" setting, this should be "M" for minimal and "V" for verbose.

    A few notes on duplications:
    - If duplicate is set to "Y", then the service will run the application only if the currently running application instance wasn't started by the service. So if "python.exe" is already running and you start the service, another "python.exe" will be started by the service, but when the service checks for running applications after the interval, it will not run "python.exe" again (unless it stopped for some reason). The service will know which python it started by using process IDs.

    - Normally if you use duplication, you'll probably want to set "close_on_exit" to "Y" as well, because when you stop the service, the service "forgets" which applications it started to it will start the process again when you start the service again.

    Anywho, get the new shiny version here:
    Installer: https://www.box.com/s/qm8fhfygcjw4rs1zwpbf
    Source: https://www.box.com/s/2a3cnb4datb2ey6878h8


    UPDATE 2013/03/20:

    Version 0.2 released.

    Not really much in this release, just a fix for Calibre's calibre-server not playing nice with the service.
    Install: https://www.box.com/s/bbbdsscjafajo9cuzdwi
    Source: https://www.box.com/s/j5qtizv2aq2pjhx6grzx


    [Original Post]

    Hi all,

    I've written a service (C# Windows service) that allows you to run any program like a service.

    First, some background:
    I have a few programs that I want to always be running (SickBeard, CouchPotato, No-IP DUC and some others), and due to power cuts/surges/dips, my computer restarts quite often. I set the computer up so that it comes on automatically after a power cut, but the other problem is that unless I log into my user account, the programs won't start because they're not services.

    So I decided to just make my own service that will run the programs automatically. You install the service and define a list of programs that you want to always be running, and the service will check periodically (interval can also be defined) if the programs are running and run any programs that are in your list and are not currently running. If a problem occurs while trying to run a program, the service will not try to run that program again until the service is restarted. It logs all errors and some messages to the event log.

    I've been running it for 2 days now and it's working nicely . I figured maybe it will be of use to others as well, and so I decided to release a version 0.1 beta. I'm also releasing the source code for scrutiny.

    Installation:
    Download the installer linked to below and run it. Select a download location and install. During installation you will need to enter the credentials of a user that you want to run the programs as (probably your account), and can write to the event log (an admin account).

    Setup:
    After installation, go to your installation directory (default C:\Program Files\Blaq Entertainment\Application Service Maker) and open the file ApplicationService.exe.config with notepad or any other text editor. Find the following section:
    Code:
    <ApplicationService.Settings>
    	<setting name="TimerIntervalMinutes" serializeAs="String">
    		<value>20</value>
    	</setting>
    	<setting name="ApplicationList" serializeAs="String">
    		<value>{app1;path}{app2;path}</value>
    	</setting>
    </ApplicationService.Settings>
    TimerIntervalMinutes is the time in minutes that the service should wait before checking/running programs.

    ApplicationList is the list of programs that you want the service to check and run. The format is "{app;path}{app;path}{appn;path}".
    "app" is the exe's name e.g. SickBeard (you can find this by opening the Windows task manager and clicking the processes tab).
    "path" is the path to the exe (in the task manager, right click the process and select "Open file location").

    Here are my current settings to give you a real example:
    Code:
    <ApplicationService.Settings>
    	<setting name="TimerIntervalMinutes" serializeAs="String">
    		<value>20</value>
    	</setting>
    	<setting name="ApplicationList" serializeAs="String">
    		<value>{SickBeard;C:\SickBeard\SickBeard.exe}{DUC30;C:\Program Files (x86)\No-IP\DUC30.exe}{LogMeIn;C:\Program Files (x86)\LogMeIn\x64\LogMeIn.exe}</value>
    	</setting>
    </ApplicationService.Settings>
    After configuring the settings, save the file and close it.
    Now go to services (start, type "services.msc" and enter), find the service named "Application Service Maker", right click it and select "Start". You should then receive a call from a strange fellow named Bob, claiming to be your uncle.

    Now what?:
    At this point it might seem like nothing spectacular happened, but behind the scenes there was a bit of action.

    Go to the event viewer, expand Windows Logs and then Application on the left. The service will write messages to the event viewer under the source "ApplicationService".

    When the service starts, it will write
    Code:
    Application service started.
    TimerIntervalMinutes: 20
    Applications to start: 
    SickBeard (C:\SickBeard\SickBeard.exe)
    DUC30 (C:\Program Files (x86)\No-IP\DUC30.exe)
    LogMeIn (C:\Program Files (x86)\LogMeIn\x64\LogMeIn.exe)
    When the service runs an application, it will write
    Code:
    Attempting to start application: SickBeard (C:\SickBeard\SickBeard.exe)
    If something goes wrong while trying to run a program, it will write (this will change depending on the error)
    Code:
    An error has occured in the application ApplicationService.
    Error Location: ServiceStartApplications.StartApplication.
    System.Exception: An error occurred when starting an application.
    ApplicationName: SickBeard
    PathToProcess: C:\SickBeard\SickBeard.exe
     ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
       at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
       at System.Diagnostics.Process.Start()
       at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
       at System.Diagnostics.Process.Start(String fileName)
       at ApplicationService.ServiceStartApplications.StartApplications()
       --- End of inner exception stack trace ---
    If the program is already running, it will write
    Code:
    Application LogMeIn (C:\Program Files (x86)\LogMeIn\x64\LogMeIn.exe) has started, no need to start it.
    There's a few other messages, but I'm sure you get the picture, the messages are meant to give you a good enough idea of what's going on.

    Now your computer can restart and the service will automatically launch your programs.

    Downloads:
    Phew, this is probably my longest post yet . Without further ado, here's some links.

    Installer: http://www.box.com/s/3imdtksvyz2k89f7r2la
    Source code: http://www.box.com/s/5qujeg4n61hfitbts18k
    The source code is in a 7zip archive: http://www.7-zip.org/download.html

    If the concept interests you, please give it a bash and leave your feedback here. I'll welcome all comments with a . Enjoy!
    Last edited by efitol; 23-03-2013 at 01:40 PM.
    Application Service Maker - Run any program as a service

    'Coz only the BEST in the land are good enough for Simba, the only taste that ROARS with flavour!

  2. #2

    Default

    This is an interesting concept, but I can't think of many practical uses for it.

    Question:

    Let's assume I have multiple users on one PC. (True)
    I download torrents quite frequently. (True)
    I experience frequent power cuts. (Not true as yet)

    So I use this application to run Bittorrent as a service. I leave for work,
    and while I'm gone there's a power cut at home for 10 minutes.

    The power comes back on and my PC automatically boots up to the login
    screen.

    Will Bittorrent automatically launch as a service and start downloading again even
    though I'm not actually logged in?

    Or do I have absolutely no idea what I'm talking about and this application serves
    an entirely different purpose?

  3. #3

    Default

    Quote Originally Posted by Totempole View Post
    This is an interesting concept, but I can't think of many practical uses for it.

    Question:

    Let's assume I have multiple users on one PC. (True)
    I download torrents quite frequently. (True)
    I experience frequent power cuts. (Not true as yet)

    So I use this application to run Bittorrent as a service. I leave for work,
    and while I'm gone there's a power cut at home for 10 minutes.

    The power comes back on and my PC automatically boots up to the login
    screen.

    Will Bittorrent automatically launch as a service and start downloading again even
    though I'm not actually logged in?

    Or do I have absolutely no idea what I'm talking about and this application serves
    an entirely different purpose?
    It has practical use in business, for example when you need to restrict user access. Some applications require administrative privileges, and you don't necessarily want to give end users this. Running an application as a service with admin credentials will allow you to work around this.

    Also, if you're thinking more enterprise, you can introduce redundancy to some business critical applications via a cluster if you have the application running as a service. I suppose it would be possible anyway by adding a generic application resource, but having it run as a service is just so much better for a bunch of reasons.

    Lots of other reasons why you would want to do this. Thanks for sharing efitol - if I may ask, what's the difference between this and srvany that MS added as part of the Windows Resource Kit? Sorry I haven't done this in a while, but is it related to WRK not being available for Windows 7/Server 2008?
    Solve two of the world's major problems: feed the homeless to the hungry

  4. #4
    Senior Member krono9's Avatar
    Join Date
    Sep 2009
    Location
    Durbanville, Cape Town
    Posts
    487

    Default

    Will this be able to run dropbox as a service? I have comodo(which runs in service mode already) that makes an automatic backup to a dropbox, but always have to logon before the dropbox will sync online....

  5. #5
    Grandmaster efitol's Avatar
    Join Date
    Oct 2005
    Location
    Neither nor
    Posts
    3,306

    Default

    Quote Originally Posted by Totempole View Post
    This is an interesting concept, but I can't think of many practical uses for it.

    Question:

    Let's assume I have multiple users on one PC. (True)
    I download torrents quite frequently. (True)
    I experience frequent power cuts. (Not true as yet)

    So I use this application to run Bittorrent as a service. I leave for work,
    and while I'm gone there's a power cut at home for 10 minutes.

    The power comes back on and my PC automatically boots up to the login
    screen.

    Will Bittorrent automatically launch as a service and start downloading again even
    though I'm not actually logged in?

    Or do I have absolutely no idea what I'm talking about and this application serves
    an entirely different purpose?
    Yes, in that situation the service will be able to start your bittorrent client (let's say utorrent) automatically from the login screen without you having to log in, and utorrent will behave just as it would if you had launched in, i.e. start downloading your torrents.

    Quote Originally Posted by Mike Hoxbig View Post
    It has practical use in business, for example when you need to restrict user access. Some applications require administrative privileges, and you don't necessarily want to give end users this. Running an application as a service with admin credentials will allow you to work around this.

    Also, if you're thinking more enterprise, you can introduce redundancy to some business critical applications via a cluster if you have the application running as a service. I suppose it would be possible anyway by adding a generic application resource, but having it run as a service is just so much better for a bunch of reasons.

    Lots of other reasons why you would want to do this. Thanks for sharing efitol - if I may ask, what's the difference between this and srvany that MS added as part of the Windows Resource Kit? Sorry I haven't done this in a while, but is it related to WRK not being available for Windows 7/Server 2008?
    Thanks for the input.

    To be honest I had not heard of srvany until now, but I had a quick look and it does seem to do the same thing. I suppose this service would be easier to setup than srvany for beginners as they won't need to prod the registry.

    Quote Originally Posted by krono9 View Post
    Will this be able to run dropbox as a service? I have comodo(which runs in service mode already) that makes an automatic backup to a dropbox, but always have to logon before the dropbox will sync online....
    It should, yes.


    Sent from my Galaxy Note
    Application Service Maker - Run any program as a service

    'Coz only the BEST in the land are good enough for Simba, the only taste that ROARS with flavour!

  6. #6
    Super Grandmaster fxit_man's Avatar
    Join Date
    Sep 2006
    Location
    Gangsters Paradise (jhb)
    Posts
    6,110
    Blog Entries
    2

    Default

    Thanks, this should probe useful for my future NAS
    For more iAdvice head over to:
    http://iPhoneZA.co.za

    iPhoneographers - Check out http://appleofmyi.co.za

  7. #7
    Grandmaster efitol's Avatar
    Join Date
    Oct 2005
    Location
    Neither nor
    Posts
    3,306

    Default

    Third day now, and many dips have occurred due to the weather (I assume) and my programs are all running even though I have yet to log in to my server .

    Quote Originally Posted by fxit_man View Post
    Thanks, this should probe useful for my future NAS
    Cool, let us know how it goes.
    Application Service Maker - Run any program as a service

    'Coz only the BEST in the land are good enough for Simba, the only taste that ROARS with flavour!

  8. #8
    Grandmaster efitol's Avatar
    Join Date
    Oct 2005
    Location
    Neither nor
    Posts
    3,306

    Default

    Quite a few downloads but no feedback, so I'll just apply the HelloPeter principle and assume that it's working fine then
    Application Service Maker - Run any program as a service

    'Coz only the BEST in the land are good enough for Simba, the only taste that ROARS with flavour!

  9. #9

    Default

    This is useful for my server - we have automated backups going to a dropbox folder. I want to make sure dropbox always runs and does it's thing, so I'm going to run it with this and let you know how it goes.

    So juts to understand it properly - does it run the app as an alias? Dropbox for example works off a user account.

    Ta!

  10. #10

    Default

    Nice concept! Will give it a try and see how it goes.
    Thx

  11. #11
    Grandmaster efitol's Avatar
    Join Date
    Oct 2005
    Location
    Neither nor
    Posts
    3,306

    Default

    Yay, users

    Quote Originally Posted by MyDogHasNoNose View Post
    This is useful for my server - we have automated backups going to a dropbox folder. I want to make sure dropbox always runs and does it's thing, so I'm going to run it with this and let you know how it goes.

    So juts to understand it properly - does it run the app as an alias? Dropbox for example works off a user account.

    Ta!
    The apps should run as whatever user you configure to run the service.

    Quote Originally Posted by n!tro View Post
    Nice concept! Will give it a try and see how it goes.
    Thx
    Cool, let us know.
    Application Service Maker - Run any program as a service

    'Coz only the BEST in the land are good enough for Simba, the only taste that ROARS with flavour!

  12. #12
    Super Grandmaster
    Join Date
    Feb 2005
    Location
    Previously this post ->
    Posts
    24,048

    Default

    How does this compare to FireDaemon? Is it a free version?
    Quote Originally Posted by reactor_sa
    ^ fountain of knowledge

  13. #13
    Grandmaster efitol's Avatar
    Join Date
    Oct 2005
    Location
    Neither nor
    Posts
    3,306

    Default Re: Application Service Maker - Run any program as a service

    Quote Originally Posted by Fudzy View Post
    How does this compare to FireDaemon? Is it a free version?
    I suppose it's like FireDaemon but free, yes

    I just needed something quickly and I was in the mood to do it myself so I did.
    Application Service Maker - Run any program as a service

    'Coz only the BEST in the land are good enough for Simba, the only taste that ROARS with flavour!

  14. #14

    Default

    I'll be having a look at this, i have alot of little things that need to be automated on the server and while i -can- write services in c# it's still much easier to write normal windows apps (with an actual screen) and have that run as services with pre-set parameters. Simple example is an app that needs to monitor a folder and pick up excel/csv files and move this into the database, quite often something fails and you need to be able to do this manually via the same app. I'm also not a big fan of having windows services handling alot of file related tasks , connecting to databases which often needs a user intervention , but it's still great if you got your app all working and can just load it into an app to "run as service" .

    Currently i'm trialling AlwaysUp : http://www.coretechnologies.com/products/AlwaysUp/ , which costs money but works brilliantly. I suppose it's the same as FireDaemon.

    So i will have a look at this too, since in the end this is something you'd use on multiple servers .

  15. #15

    Unhappy Loooooooooove this thingie but.........................

    Take a look at Belvedere. It works like a charm, especially in conjunction with this.


    @efitol

    I am using your app, it works like a charm, except for Calibre.....
    When I run calibre-server from the command-line it works, running that same commandline through your service does not start the server.

    I made sure that in both situations it was run under the same account (administrator in Windows 8)

    I do not get any error-logging, just an information in application log saying it is trying to start calibre-server.
    Any suggestions?

    <value>{calibre-server;C:\Program Files (x86)\Calibre2\calibre-server.exe}{Belvedere;C:\Program Files (x86)\Belvedere\Belvedere.exe}{Dropbox;C:\Users\He nro\AppData\Roaming\Dropbox\bin\Dropbox.exe}</value>

    C:\Program Files (x86)\Calibre2\calibre-server.exe runs great when started from commandline (as administrator and without elevated rights) and from WIN+R, again with and without administrative rights. It runs great when called from a batch file upon login. But not with your service...... Suggestions?

    For now I am starting it like this:

    http://www.mobileread.com/forums/showthread.php?t=74683
    Last edited by henro; 26-02-2013 at 10:37 PM. Reason: workaround

Page 1 of 2 1 2 LastLast

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •