Jump to content



Photo

Run a program as a Service


  • Please log in to reply
20 replies to this topic

#1 Popcorned1

Popcorned1

    Neowinian Senior

  • 2,164 posts
  • Joined: 03-October 04

Posted 26 February 2006 - 11:37

How to Run a Program as a System Service!

Step 1 : Download and install srvtools.zip, this can be downloaded from the Microsoft website HERE

Step 2 : Once installed find the two files named as follows : instrv.exe and srvany.exe and copy them to the folder where the exe lies for the program you want to make a service.

Step 3
: Open up the command prompt and type in the following. For the example I'm using a folder called "example" :

cd "C:\example\"
This puts command prompt into the folder where your program lies.

instsrv Servicename"C:\example\srvany.exe"
This installs the program as the service. Yes!
Replace Servicename with your own service name.

Some registry editing to go and then were done.

REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Servicename\Parameters]
"Application"="\"C:\\example\\example.exe\""
Save as a *.reg file and simply double click to run it.
You can also see you need to replace the Servicename and the directory with the service name and your program folder you made earlier.

C & C's welcome.

Edited by Popcorned, 26 February 2006 - 15:32.



#2 nomis_nehc

nomis_nehc

    Neowinian God!

  • 5,440 posts
  • Joined: 22-December 01

Posted 26 February 2006 - 12:21

how does running a program as a service benefit? i am curious and am sure that others are too. also, will it show up in services under admin tools?

#3 OP Popcorned1

Popcorned1

    Neowinian Senior

  • 2,164 posts
  • Joined: 03-October 04

Posted 26 February 2006 - 14:31

Yes, it shows in the service panel so you can also allow it to interact with the desktop. The advantage of this is that the program is going to run on system boot. So if you need a software to run for some reason without stopping this can do it. I don't know exactly why you want to do this, but I think it's helpfull for those times when you might need it.

#4 medium_pimpin

medium_pimpin

    Boner Soup

  • 3,018 posts
  • Joined: 22-February 06
  • Location: Lexington, KY USA
  • OS: Windows 7, 8.1/Linux Mint
  • Phone: Samsung Galaxy S3

Posted 26 February 2006 - 14:35

Running an app as a service is especially helpful on servers, where a program may need to run even if no users have an active session.

#5 tony-inpo

tony-inpo

    Neowinian Senior

  • 2,440 posts
  • Joined: 13-June 05
  • Location: Isle of Wight, UK

Posted 26 February 2006 - 14:37

Nice one I think just about every programmer asks this question at one time or another

Edit> This first 'HERE' link doesn't do anything

#6 shooter468

shooter468

    Neowinian

  • 224 posts
  • Joined: 29-July 05

Posted 26 February 2006 - 15:04

srvtools can be found here
srvtools.zip

#7 OP Popcorned1

Popcorned1

    Neowinian Senior

  • 2,164 posts
  • Joined: 03-October 04

Posted 26 February 2006 - 15:33

That's wrong Shooter, updated the original topic with the link.

Cheers! :D

#8 shooter468

shooter468

    Neowinian

  • 224 posts
  • Joined: 29-July 05

Posted 26 February 2006 - 16:21

oops... :blush:

#9 DigeratiPrime

DigeratiPrime

    UNSTOPPABLE!!!

  • 410 posts
  • Joined: 29-November 04
  • Location: Mastic Beach, NY

Posted 26 February 2006 - 18:34

i found INSTSRV.EXE and SRVANY.EXE here:
http://www.electraso...vany/srvany.htm

i put the two files inside the Winpooch folder and created two files:

WP_Service.cmd
instsrv Winpooch "D:\Program Files\Winpooch-0.5.10\srvany.exe"

WP_Service.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Winpooch\Parameters]
"Application"="\"D:\\Program Files\\Winpooch-0.5.10\\Winpooch.exe\""

and ran them in that order. I do have a Winpooch entry in Services.msc and I see it in Autoruns, but it doesnt work when i try to start it. :(

Edited by DigeratiPrime, 26 February 2006 - 18:56.


#10 DaveLegg

DaveLegg

    Coderator at heart

  • 7,660 posts
  • Joined: 31-October 04
  • Location: Oxford, UK

Posted 26 February 2006 - 18:39

Might be you don't have it set ti allow to interact with desktop, so you see no windows.

I use this method to run Hamachi all the time from system boot, very handy. I have also set it up to run command prompt, so if I ever need anything, I can get a command prompt running as system, which allows me to reset permissons and stuff, if I ever bork them up. Also, if you want to live really dangerously, you can use this command prompt to run any other app (like IE if you feel brave) as System.

#11 OP Popcorned1

Popcorned1

    Neowinian Senior

  • 2,164 posts
  • Joined: 03-October 04

Posted 26 February 2006 - 18:41

Lets have a looksy, oh look a error

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Servicename\Parameters]
"Application"="\"D:\\Program Files\\Winpooch-0.5.10\\Winpooch.exe\""

Replace that with Winpooch

Try now.

#12 DigeratiPrime

DigeratiPrime

    UNSTOPPABLE!!!

  • 410 posts
  • Joined: 29-November 04
  • Location: Mastic Beach, NY

Posted 26 February 2006 - 18:55

its working! :)

#13 jimbo12141

jimbo12141

    Neowinian Senior

  • 2,377 posts
  • Joined: 09-June 05
  • Location: Norwich, England

Posted 26 February 2006 - 22:02

woot thanks for the guide!

#14 OxideNOS

OxideNOS

    OxideNOS

  • 1,092 posts
  • Joined: 01-November 04
  • Location: NJ

Posted 27 February 2006 - 19:16

Will be helpful for my FTP Server. Thanks a lot for a great guide.

#15 WepX

WepX

    Neowinian

  • 2 posts
  • Joined: 22-April 03

Posted 27 February 2006 - 20:37

Firstly Hi all...great forums :)
Thanks for the guide but I seem to be having some probs.
I am trying to have Speedfan as a service and just cant seem to get it going.I have followed the instructions given,replacing servicename and directory etc.
Speedfan wont even show up in services.
Any idea what Im doing wrong?

the directory is D:\Program Files\Speedfan and I was going to call the service simply Speedfan.
I began as follows...

cd "D:\Program Files\Speedfan\"

then followed with....

instsrv Speedfan"D:\Program Files\Speedfan\srvany.exe"

with which Ii get this......

Installs and removes system services from NT

INSTSRV <service name> (<exe location> | REMOVE)
[-a <Account Name>] [-p <Account Password>]

Install service example:

INSTSRV MyService C:\MyDir\DiskService.Exe
-OR-
INSTSRV MyService C:\mailsrv\mailsrv.exe -a MYDOMAIN\joebob -p foo

Remove service example:

INSTSRV MyService REMOVE

This is my reg file...

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Speedfan\Parameters]
"Application"="\"D:\\Program Files\\Speedfan\\speedfan.exe\""

Any help much appreciated.
Thanks,
Ray