Running an application as a service

Discussion in 'Operating Systems' started by Shadowspawn, Sep 15, 2006.

  1. Shadowspawn

    Shadowspawn [H]ard|Gawd

    Messages:
    1,906
    Joined:
    Sep 17, 2002
    I have a small executable that I need to run as a service in a fully updated Server 2003. If memory serves, NT had tools built in to do this, but my Google searches only turn up third party applications, nothing native to 2003. Anybody have experience doing this?
     
  2. Axeldoomeyer

    Axeldoomeyer Limp Gawd

    Messages:
    290
    Joined:
    Jun 3, 2006
    You will need to use the SRVAny.exe in the 2003 resource kit. I don't remember the switches or how to do it off the top of my head and I can't seem to find my notes on it at the moment.

    Hope this helps
     
  3. morpheus6d9

    morpheus6d9 [H]ard|Gawd

    Messages:
    1,229
    Joined:
    Mar 11, 2005
    i had the same problem as well i just ended up running it as a scheduled task
     
  4. djnes

    djnes Pick your own.....you deserve it.

    Messages:
    19,746
    Joined:
    Mar 24, 2000
  5. t00thless

    t00thless Limp Gawd

    Messages:
    474
    Joined:
    Oct 6, 2004
    srvany.exe/instsrv.exe are supposed to do this. however, the two times i've needed to create a service, they didn't work.

    here is my work-around if you do not/can not buy 3rd party software: put a shortcut to the .exe in the startup folder. download power toys tweak UI and set the server to auto-login; this is incase the server reboots. now, set the screen saver to start after one minute and to password protect.

    ghetto? yep! but it works and the server is only un-protected for one minute.
     
  6. Axeldoomeyer

    Axeldoomeyer Limp Gawd

    Messages:
    290
    Joined:
    Jun 3, 2006
    I too have had problems with them in the past. I think that it depends on the way that the .exe was coded. The only problem with putting the program in the startup is if the program fails you may not know that the program failed and it would have no way of restarting the app. I guess this is just a catch 22. If anyone has a better solution I would like to hear it. :)
     
  7. duby229

    duby229 2[H]4U

    Messages:
    3,015
    Joined:
    May 1, 2005
    oooohhhh Rights escalation....

    Remember the good ol' days when you could replace one of the services with cmd.exe and get admin rights? Ah the good times we once had. :D
     
  8. morpheus6d9

    morpheus6d9 [H]ard|Gawd

    Messages:
    1,229
    Joined:
    Mar 11, 2005
    one minute is all someone really needs could just set it up as a scheduled task
     
  9. Shadowspawn

    Shadowspawn [H]ard|Gawd

    Messages:
    1,906
    Joined:
    Sep 17, 2002
    I apologize for taking so long to reply. This program needs to be running at all times, no matter who logs into the server. Thats why I cannot use the startup folder. Our site has been having power problems which has caused the servers to reboot and nobody notices until our customers complain several hours later. So if I can run the application as a service then it will be up and running immediately after the reboot, whether or not anyone logs on.

    I will give the srvany.exe/instsrv.exe files a try. I think those are the files I remember from NT days. If this fails, then toothless's suggestion may be the way to go - although it will only work for the primary admin account and I would like the application to be running no matter what account logs in.

    I will let you know what happens, in case anyone else needs help.
     
  10. Shadowspawn

    Shadowspawn [H]ard|Gawd

    Messages:
    1,906
    Joined:
    Sep 17, 2002
    Just to help anybody else that needs to create a service out of an application that isn't coded to run as a service:

    The resource kit for NT/2000/2003 includes srvany.exe and instsrv.exe. These files let you create a service that runs srvany.exe as a service. Srvany.exe then can load any executable automatically. This works great and resolved my issue.

    Thanks for the advice guys.

    BTW, SC.exe doesn't run non-service coded applications.