PDA

View Full Version : [Tutorial] Run your client as a service



Sazzy
18.02.14, 20:10
Having recently set up a dedicated file server at home, I decided to move my torrent client to this machine instead. The machine's currently also set up as a media center running on top of Windows 8.1 and is hooked up to my tv set.

The annoying thing with this setup, however, is that you have to log in and start the torrent client before it will actually download anything. Since I often turn on the machine with a Wake On Lan packet I send out with my phone, it's a hassle having to manually log in.

To fix this, there are two options. Didn't find any thread related to this on sb-i, so I thought I'd share~

First option is to let windows automatically log in. I don't prefer this, but I thought i'd put it down here anyway. You can achieve this by pressing Win+R. The "run" prompt now appears. In the box, type in netplwiz. Uncheck the option "Users must enter a user name and password to use this computer.". Press apply and supply the account and password that will be used to log in. If you configure your client to auto start up, you will be home free. Since I personally don't like this way of working (as you have to circumvent the password security), I looked up another option.

~~~~~~~

Second way to achieve it, is running your client as a service. On newer windows you can easily create a service using powershell. (If at any point one of the commands isn't working, try looking up how to use SRVANY.exe.)


First you need to configure your client, preferably with a dedicated windows account that you will be using to run the torrent client on. Set up a web remote to access the client with remotely (e.g. Vuze remote for vuze, WebUI for uTorrent, ...)


Then you need to create the windows service. This will be done with the "New-Service" commandlet. Open a powershell console as administrator and type:


new-service TorrentService "C:\Program Files\PathTo\YourClient.exe"

After creating the service, you can find it again in a GUI by pressing Win+R again and this time running "services.msc". Right click and select properties to configure the service visually.

Startup type: Automatic
Log On: Select "This Account"

Select browse and select the account you used to configure the client.
This is important because settings are mostly stored in the AppData folder for that account (so they are account based!)

Type in the accounts password.
Click apply -> ok


It's generally wise to restrict that account so it only has rights to the download folder and doesn't have any remote desktop rights (nor admin rights!)



Note: if you want to delete the service again, run the following powershell commands:


$serviceToRemove = Get-WmiObject -Class Win32_Service -Filter "name='TorrentService'"

$serviceToRemove | Stop-Service

$serviceToRemove.delete()



Of course, this isn't limited to just your torrent client. If you want, you can create a service for other tools as well. Dropbox is another useful tool to have running as a service. (Don't forget to turn off desktop notifications before running it as a service.)



Feel free to ask questions if you're having trouble with something. Happy to help out!

Lucius
18.02.14, 20:51
Why running the client as a service anyway ?
I can just make it auto start with windows.

Thanks for the tutorial, that's my first time reading such information.

Sazzy
18.02.14, 21:02
You have to log in to make it auto start with windows, which requires manual intervention or not setting up a password on your pc.
As soon as you log out, the client will stop running as well.

Running it as a service circumvents that.

Note that this is meant for a headless pc, not for your desktop.

anon
19.02.14, 03:29
Log On: Select "This Account"
Select browse and select the account you used to configure the client.
This is important because settings are mostly stored in the AppData folder for that account (so they are account based!)

As an additional tidbit, I wanted to point out that if you didn't do this, the client would run under the NT AUTHORITY\SYSTEM account, which due to how Windows lays out NTFS and registry permissions, is the de facto absolute power under NT; even higher than an administrator account. And with the right programs you can easily make it run anything else you want on demand, very useful for deleting clingy directories and registry keys.

RunasSystem and RunFromToken - reboot.pro (http://reboot.pro/files/file/237-runassystem-and-runfromtoken/)
RunAtWinlogon - reboot.pro (http://reboot.pro/files/file/255-runatwinlogon/)

shadowww
21.02.14, 01:12
Why running the client as a service anyway ?


To hide in on some PC with fat pipe and use it as your secret seedbox. :biggrin:

Sazzy
21.02.14, 07:59
To hide in on some PC with fat pipe and use it as your secret seedbox. :biggrin:

Good point :lol:

Nah, it's just so much easier this way when building your own NAS from scratch or running a WHS box and for some reason decide you feel better with having windows on there instead of linux. (which is the case for me)
The box' ram stays clear from having a full profile loaded up with explorer.exe and all the other extra's, since you don't have to log into the machine to start the service.

Lucius
21.02.14, 10:34
Good point :lol:

Nah, it's just so much easier this way when building your own NAS from scratch or running a WHS box and for some reason decide you feel better with having windows on there instead of linux. (which is the case for me)
The box' ram stays clear from having a full profile loaded up with explorer.exe and all the other extra's, since you don't have to log into the machine to start the service.

wow, so we can make a semi-non-GUI windows computer. But is there a side effects of using this approach ?
you gave a note of disabling the desktop notification of some app.
I hope we can make mR running as a service, maybe a web UI for mR will be a great feature request :D

anon
21.02.14, 19:09
wow, so we can make a semi-non-GUI windows computer.

Someone made a custom XP that includes only the Command Prompt interface and needs 10 MB of disk space. Not everything works on it, but if the programs you want do, it's perfect to repurpose an old computer as a NAS. Think it was called "XPCLI" or something like that.

Sazzy
21.02.14, 19:30
wow, so we can make a semi-non-GUI windows computer. But is there a side effects of using this approach ?
you gave a note of disabling the desktop notification of some app.
I hope we can make mR running as a service, maybe a web UI for mR will be a great feature request :D

No side affects that I know of, anyway.
Services don't have access to the desktop, thus for dropbox you have to disable that feature to keep it happy.


Someone made a custom XP that includes only the Command Prompt interface and needs 10 MB of disk space. Not everything works on it, but if the programs you want do, it's perfect to repurpose an old computer as a NAS. Think it was called "XPCLI" or something like that.

Could just run freedos (http://www.freedos.org/)in that case! :)