Archive for November 16th, 2012

OK, so I promised to do a post on how to run the Windows version of the Minecraft server as a psuedo service.

I don’t intend to get into the ins and outs of the server.properties file, see Google for that 😛

To get the bad news out of the way, whilst it does run in a service like mannner, it won’t shut down. You have to kill the javaw.exe or javaw.exe *32 process, then go and set the services to stopped in the services console (Services.msc if you want to run it manually).

It does however run GUI less and allows you to log off the server whilst it remains running. If you also specify different ports, you can have multiple ‘Services’ running and serving up MineCraft. I currently have 2 running happily side by side on slightly different ports.

Bad news out of the way, you can set it to auto start, and it works quite happily, restarting your MineCraft server after a reboot 🙂

So, how do I do this chicanery you ask?

There are only two tools you need TBH, one of which is built into Windows 2003, Windows 2008 and Windows 7, and the other is freely downloadable as it’s part of the Windows 2003 Resource Kit.

Here’s the steps you need, based on my install which has the MineCraft server executable installed into a directory on the E: drive of my server called Minecraft. Don’t forget to replace e:\Minecraftt with your own directory.

2. Download Minecraft_Server.exe to the directory you created at step 1. Run it once to create the file and directory structures it needs.

3. Download srvany.exe to the directory you created in step1. Google it, you can’t fail to find it.

4. Open a command prompt and type the following, ensuring the space is present after the = sign: sc create Minecraft binpath= e:\Minecraft\srvany.exe

5. Hit enter. The base service is now created. Don’t worry if you stuff it up, just type: sc delete Minecraft and it’ll be gone 🙂

6. A little work remains. Execute the comand regedt32.exe from the run box and locate HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Minecraft in the registry.

7. Right click on the Minecraft key, and select ‘New’ then ‘Key’. Name the new key Parameters.

8. Right click on the new created Parameters key, and select ‘New’ and ‘String Value’. Give the new string the value AppDirectory, and give it the value e:\Minecraft

9. Create another new string value called Application with the value e:\Minecraft\Minecraft_Server.exe

10. Create another new string value called AppParameters with the value server.properties

11. Finally execute services.msc from the run box. Locate the Minecraft service you just created and double click on it.

12. In the general tab set the startup type to be Automatic, and on the log on to be Local System Account.

13. Click ‘Start’ and off your Mincraft server goes. Just check for the presence of javaw.exe or javaw.exe *32 in Task Manager.

14. Log off your server, in the knowledge that Mincraft will continue to run whilst you’re away 🙂

15: Go play Minecraft and connect to your server.

One last thing, is that if you do decide you want to run multiple servers, make sure you name the services you create differently i.e. Minecraft, Minecraft2 etc, and set the port in the server.properties file. You’ll also need to create a separate directory with s different containing all the Minecraft files, as you can only run one site per folder. I use e:\Minecraft and e:\Minecraft2.

If you’re having issues with the server.properties file not being read, make sure all the AppDirectory and AppParamters are set correctly. You can also add server.properties to the Start Parameters field of the service.

As I said, it is a sort of pseudo service, in that it doesn’t stop when you stop the service, so you have to kill the process, but it is better than having to stay logged on to your server.

One word of advice if you do end up running more than one server on the same box, is to make a note of the PID of one javaw process so you don’t close the wrong one down by accident.

An export of my Minecraft service reg key is below. You can modify the directory names to suit and import into your registry, just make sure you create the service first.

By the way, only do this if you’re confident you’re not going to stuff up your server, as despte having tested these instructions thoroughly, I can’t be held responsible for what you decide to do to your own server 😛