So I have recently set up my own Windows Server 2012 box to replace my old NAS. There was nothing wrong with the old box particularly, I just wanted a bit more control over it all, and I wanted to be able to run Plex, which the old box just wasn’t powerful enough to handle. One of the features of the NAS box was that it has a BitTorrent client, accessible via a web browser, and I was keen to replicate this functionality on my new set up.
The popular µTorrent client seemed like a good solution, as it includes a web-based user interface out of the box. Unfortunately, there is no built-in way to get it to run without being actually logged into the server at the time. The usual trick of setting up a scheduled task to run at start up unfortunately didn’t seem to work, and all of the guidance I could find on the internet suggested that I use the Windows Server 2003 Resource Kit to create a service, which unfortunately seems to be incompatible with Windows Server 2012!
So, in the end I gave in and came up with my own solution, and I thought I would write about it here in case it is of any use to anyone else trying to achieve the same thing.
First things first – I had to get the µTorrent client working on my server. I created a user account just for this purpose, logged in with it, and ran through the set up procedure. Once it was installed, I opened the client and configured it to my liking, making sure to enable the web UI option!
Secondly, I fired up Visual Studio 2012 and built a very small service executable that simply runs the client for me. You can grab the source code on GitHub, or if you’re not much of a coder, you can download a compiled version of this executable here.
I copied the compiled executable to my server, placed it in the same directory as the µTorrent client (type “%AppData%\uTorrent” into the address bar), and installed it using the following command line (you will need an elevated Command Prompt – right click and Run as Administrator):
SC CREATE uTorrent binPath= C:\Wherever\You\Copied\uTorrentService.exe start= delayed-auto obj= .\YourServiceAccount password= Password
Once installed, I could then simply start the new uTorrent service from the Services control panel, and hey presto, everything was working!