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.
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.