PDA

View Full Version : FileSharing How to set up your p2p client as a service



lynx
01-18-2008, 11:42 AM
This feature allows you to have your p2p client running without needing to be logged on.
This means that if you have to log off for any reason your p2p client will still be running in the background, and it will start up with the system, not when you log on.

First of all, you need a program from Microsoft's Resource kit tools - srvany.exe - to act as the interface between windows service manager and your application. I can't include it here as it is copyright, but you can download and install the whole resource kit tools from Microsoft:
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en
This version is intended for Server 2003, but the program we want works with all NT based versions between NT3.51 and XP and should work with Vista too. It doesn't work with Win9x or WinME, but who cares.

Ok, first you need to create a service. You need admin rights to do this, and you need the following information:
<location> of srvany.exe - the full path.
<service name> for the service - what it is called internally
<display name> for the service - what you see in service manager - if you leave this out you will get the service name
If any entry contains spaces then enclose it in double quotes.

Select Start/Run and enter the following command, replacing the <> boxes with your info. The spaces after the = signs are intentional, it won't work if you leave them out. Unfortunately, unless you've got remarkable eyesight you won't see if it works, so if you can't find your service later on you may want to run this from a command prompt.

sc create <service name> start= auto binpath= <location> displayname= <displayname>

For utorrent, it might look like this:
sc create utorrent start= auto binpath= "D:\Windows Resource Kits\Tools\srvany.exe" displayname= "Micro Torrent"

Now that you've created a service, you need to give it something to do.
Run Regedit and find the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<service name>
Right click on that key and select new->key, give the key the name "Parameters" (without the quotes).
Right click on this new key, select new->string value, give it the name "Application" (without the quotes).
Double click "Application" and enter the full path of your p2p client.

Next, you need to make it interactive (so that you can see things on the desktop).
Open Service Manager (in control panel/administrative tools) and select the service you just created. Right click and select properties, choose the "Log On" tab and tick the box that says "Allow service to interact with desktop", select OK. Don't close service manager, you'll need it in a moment.

Your service is now runnable, but there may be a one more thing you need to do to get it to work properly, depending on the application. You are no longer running this application, it is being run by LocalService, so if the application stores any information in your user profile you may have to make a copy of it in the LocalService user profile.
Look in "Documents and Settings\<Your user name>\Application Data", if there is an entry for your application you need to copy that entry into the same area for the LocalService user - "Documents and Settings\LocalService\Application Data". Some of these folders are hidden, so you may need to change your folder options so that you can see them.
For uTorrent, if you can also move the contents of "Documents and Settings\<Your user name>\Application Data\uTorrent" to the same folder as the uTorrent application, and it will use the same settings and torrent details for all users and services.

You should now be good to go - find your service in service manager, select it and click the start button at the top of the window - hopefully your application will now start.

Assuming everything is ok, you need a simple way to start and stop your application. Create two new shortcuts, the target in the first is sc start <service name>, the target in the second is sc stop <service name>. Give the shortcuts whatever names you want. The first will start your application, the second will stop it. You may be able to stop the aplication in the normal way, but this will leave the service program that called it (srvany.exe) running so you won't be able to start it again until you've stopped the service.

This method works with many applications (and not just p2p either), but I can't guarantee it will work with all of them. If you've followed everything correctly and it doesn't work that's a problem with the application, not the method.

One last thing to remember, if you are starting your application as a service then you don't want it to run at startup, so uncheck the box in the applications options, remove it from the Startup folder and so on, otherwise you may have 2 copies running when you log in.

SenorBubbz
01-29-2008, 08:53 PM
This is great man, thank you!

This could also come in handy for other things ;)

kadake
02-02-2008, 12:55 PM
are there any down points to doing this.

When you do login can you see client running ?

i know i was going to do this with PG2 but you cant see it running when you login ?

lynx
02-07-2008, 07:43 PM
The only downside I'm aware of is the need to have a copy of the parameters in the local system account, and having to remember that if you change that copy your own copy doesn't get modified automatically.

Whether you see the client window depends on how the software was written. If it has been written properly to work with XP the client window appears (already running) as soon as you log in.

Make sure you ticked the box in service manager marked "Allow service to interact with the desktop". If you try to run the software under your own account (which would having a separate copy of the parameters) then the option is disabled and you can't get the service to interact with the desktop at all.

I've tried it with uTorrent and it behaves correctly. I can't really comment about other software, but if it behaves properly under fast user switching there's a good chance it will work properly as a service.

serby
02-11-2008, 02:37 PM
thanks mann ı've looking for it everywhere

alfry1010
02-21-2008, 02:07 PM
that seems useful =) but ATM it's zonealarm which get down after 24~48h :-/

Cabalo
02-21-2008, 02:55 PM
extremely useful for seedboxes.
doesn't work for azureus @ win2k3 :(

Furonem
02-27-2008, 11:59 PM
Sounds useful. I might have to try it out.

0riGiNaLBoX
05-24-2008, 05:58 PM
thanks man for this setup

lynx
06-23-2008, 08:22 PM
Added an extra bit of info about settings for uTorrent.

pio21
06-24-2008, 01:23 PM
thank you to thise very usefull trick i can use next time